diff --git a/packages/fetch-mock/src/__tests__/FetchMock/routing.test.js b/packages/fetch-mock/src/__tests__/FetchMock/routing.test.js index f6344a42..b29a351f 100644 --- a/packages/fetch-mock/src/__tests__/FetchMock/routing.test.js +++ b/packages/fetch-mock/src/__tests__/FetchMock/routing.test.js @@ -1,4 +1,4 @@ -import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; +import { beforeEach, describe, expect, it, vi } from 'vitest'; import fetchMock from '../../FetchMock'; describe('Routing', () => { @@ -250,17 +250,4 @@ describe('Routing', () => { expect(res.status).toEqual(200); }); }); - - describe('relative routes', () => { - beforeEach(() => { - fm.config.allowRelativeUrls = true; - }); - afterEach(() => { - fm.config.allowRelativeUrls = false; - }); - it('allows handling relative routes', async () => { - fm.route('/relative/path', 200); - await fm.fetchHandler('/relative/path'); - }); - }); }); diff --git a/packages/fetch-mock/src/__tests__/spec-compliance.test.js b/packages/fetch-mock/src/__tests__/spec-compliance.test.js index 994b82a6..57bb3825 100644 --- a/packages/fetch-mock/src/__tests__/spec-compliance.test.js +++ b/packages/fetch-mock/src/__tests__/spec-compliance.test.js @@ -23,6 +23,15 @@ describe('Spec compliance', () => { ), ); }); + it('rejects on protocol agnostic url containing credentials', async () => { + await expect( + fetchMock.fetchHandler('//user:password@a.com'), + ).rejects.toThrow( + new TypeError( + 'Request cannot be constructed from a URL that includes credentials: //user:password@a.com/', + ), + ); + }); it('reject if the request method is GET or HEAD and the body is non-null.', async () => { await expect( fetchMock.fetchHandler('http://a.com', { body: 'a' }),