| 61 | } |
| 62 | |
| 63 | function api(t: TestContext, expected: Expected[]): EventsGitHub { |
| 64 | const queue = [...expected]; |
| 65 | t.after(() => assert.equal(queue.length, 0, "Unused expected API requests")); |
| 66 | return new EventsGitHub("fixture-token", async (input, init) => { |
| 67 | const next = queue.shift(); |
| 68 | assert.ok(next, `Unexpected request ${init?.method} ${String(input)}`); |
| 69 | assert.equal(init?.method, next.method); |
| 70 | assert.equal(String(input), `https://api.github.com${next.path}`); |
| 71 | assert.equal(init?.redirect, "error"); |
| 72 | next.check?.(JSON.parse(String(init?.body))); |
| 73 | const status = next.status ?? 200; |
| 74 | return new Response(status === 204 ? null : JSON.stringify(next.response), { status }); |
| 75 | }); |
| 76 | } |
| 77 | |
| 78 | test("fixture cleanup uses the subscriber credential only for subscriptions", async t => { |
| 79 | const root = await temporary(t); |