Skip to content

Commit

Permalink
test: tests for deleteRoute method
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Feb 3, 2025
1 parent 0d007d6 commit e127a87
Showing 1 changed file with 16 additions and 0 deletions.
16 changes: 16 additions & 0 deletions packages/fetch-mock/src/__tests__/FetchMock/routing.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -250,4 +250,20 @@ describe('Routing', () => {
expect(res.status).toEqual(200);
});
});
describe('modifyRoute', () => {});
describe('deleteRoute', () => {
testChainableRoutingMethod(`deleteRoute`);
it('error informatively when name not found', () => {
fm.route('http://a.com/', 200).route('http://b.com/', 201, 'named');
expect(() => fm.deleteRoute('misnamed')).toThrowError(
'Could not delete route `misnamed` - route with that name does not exist',
);
});
it('deletes a route', async () => {
fm.route('http://a.com/', 200, 'named').route('http://a.com/', 201);
fm.deleteRoute('named');
const res = await fm.fetchHandler('http://a.com');
expect(res.status).toEqual(201);
});
});
});

0 comments on commit e127a87

Please sign in to comment.