Skip to content

Commit

Permalink
test: failing test for #908
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Feb 23, 2025
1 parent ec5ad60 commit f5363a7
Showing 1 changed file with 35 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -184,34 +184,44 @@ describe('response negotiation', () => {
);
});
});
it('Response', async () => {
fm.route('http://a.com/', new Response('http://a.com/', { status: 200 }));
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
});
describe('Response', () => {
it('Response', async () => {
fm.route('http://a.com/', new Response('http://a.com/', { status: 200 }));
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
});

it('should work with Response.error()', async () => {
fm.route('http://a.com', Response.error());
const response = await fm.fetchHandler('http://a.com');
expect(response.status).toBe(0);
});
it('should work with Response.error()', async () => {
fm.route('http://a.com', Response.error());
const response = await fm.fetchHandler('http://a.com');
expect(response.status).toBe(0);
});

it('function that returns a Response', async () => {
fm.route(
'http://a.com/',
() => new Response('http://a.com/', { status: 200 }),
);
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
});
it('function that returns a Response', async () => {
fm.route(
'http://a.com/',
() => new Response('http://a.com/', { status: 200 }),
);
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
});

it('Promise that returns a Response', async () => {
fm.route(
'http://a.com/',
Promise.resolve(new Response('http://a.com/', { status: 200 })),
);
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
it('Promise that returns a Response', async () => {
fm.route(
'http://a.com/',
Promise.resolve(new Response('http://a.com/', { status: 200 })),
);
const res = await fm.fetchHandler('http://a.com/');
expect(res.status).toEqual(200);
});

it('Reuse a Response', async () => {
fm.route('http://a.com/', new Response('hello', { status: 200 }));
await fm.fetchHandler('http://a.com/').then((res) => res.text());
await expect(
fm.fetchHandler('http://a.com/').then((res) => res.text()),
).resolves.toEqual('hello');
});
});

describe('rejecting', () => {
Expand Down

0 comments on commit f5363a7

Please # to comment.