Skip to content

Commit

Permalink
test: add failing test for relative url matching in node
Browse files Browse the repository at this point in the history
  • Loading branch information
wheresrhys committed Nov 8, 2024
1 parent 225a0ea commit 0c3c650
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions packages/fetch-mock/src/__tests__/router-integration.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { describe, expect, it } from 'vitest';
import fetchMock from '../FetchMock';
describe('router integration', () => {
const isBrowser = Boolean(globalThis.location);
it('matchurls when called with Request', async () => {
const fm = fetchMock.createInstance();
fm.post('http://a.com/', 200).catch();
Expand Down Expand Up @@ -65,6 +66,14 @@ describe('router integration', () => {
),
).resolves.not.toThrow();
});
if (!isBrowser) {
it('can match relative urls when allowRelativeUrls option is true', async () => {
const fm = fetchMock.createInstance();
fm.route('/path', 200, { allowRelativeUrls: true });
const res = await fm.fetchHandler('/path');
expect(res.status).toEqual(200);
});
}
});
describe('user defined matchers', () => {
it('match on sync property', async () => {
Expand Down

0 comments on commit 0c3c650

Please sign in to comment.