Repository: wheresrhys/fetch-mock
Pull request #740 (2024-07-24 01:48:57)

chore: addressed a few trivial todos


Patch:
diff --git a/.release-please-manifest.json b/.release-please-manifest.json
index 92bf706..8c261c3 100644
--- a/.release-please-manifest.json
+++ b/.release-please-manifest.json
@@ -1,4 +1,4 @@
 {
-  "packages/core": "0.3.1",
-  "packages/fetch-mock": "10.1.1"
+  "packages/core": "0.3.0",
+  "packages/fetch-mock": "10.1.0"
 }
diff --git a/package-lock.json b/package-lock.json
index c0d63b8..d4a295e 100644
--- a/package-lock.json
+++ b/package-lock.json
@@ -27159,7 +27159,7 @@
     },
     "packages/core": {
       "name": "@fetch-mock/core",
-      "version": "0.3.1",
+      "version": "0.3.0",
       "license": "ISC",
       "dependencies": {
         "dequal": "^2.0.3",
@@ -27170,7 +27170,7 @@
       }
     },
     "packages/fetch-mock": {
-      "version": "10.1.1",
+      "version": "10.1.0",
       "license": "MIT",
       "dependencies": {
         "debug": "^4.1.1",
diff --git a/packages/core/CHANGELOG.md b/packages/core/CHANGELOG.md
index b233f2e..e2c6eca 100644
--- a/packages/core/CHANGELOG.md
+++ b/packages/core/CHANGELOG.md
@@ -1,12 +1,5 @@
 # Changelog
 
-## [0.3.1](https://github.com/wheresrhys/fetch-mock/compare/core-v0.3.0...core-v0.3.1) (2024-07-23)
-
-
-### Documentation Changes
-
-* fixed tests and documented the async behaviour ([664a6df](https://github.com/wheresrhys/fetch-mock/commit/664a6df59a77937e18f19aa161ec4900fa709bfe))
-
 ## [0.3.0](https://github.com/wheresrhys/fetch-mock/compare/core-v0.2.0...core-v0.3.0) (2024-07-21)
 
 
diff --git a/packages/core/package.json b/packages/core/package.json
index c53ad0c..9ca2095 100644
--- a/packages/core/package.json
+++ b/packages/core/package.json
@@ -2,7 +2,7 @@
   "name": "@fetch-mock/core",
   "description": "Utility for creating mock fetch implementation",
   "exports": "src/index.js",
-  "version": "0.3.1",
+  "version": "0.3.0",
   "main": "index.js",
   "types": "types/index.d.ts",
   "scripts": {
diff --git a/packages/core/src/CallHistory.js b/packages/core/src/CallHistory.js
index 97169b8..fd0a833 100644
--- a/packages/core/src/CallHistory.js
+++ b/packages/core/src/CallHistory.js
@@ -181,7 +181,6 @@ class CallHistory {
 				routeNames.includes(name),
 			);
 		}
-		// TODO when checking all routes needs to check against all calls
 		// Can't use array.every because would exit after first failure, which would
 		// break the logging
 		return routesToCheck
diff --git a/packages/fetch-mock/CHANGELOG.md b/packages/fetch-mock/CHANGELOG.md
index e0237b3..33d5781 100644
--- a/packages/fetch-mock/CHANGELOG.md
+++ b/packages/fetch-mock/CHANGELOG.md
@@ -1,12 +1,5 @@
 # Changelog
 
-## [10.1.1](https://github.com/wheresrhys/fetch-mock/compare/fetch-mock-v10.1.0...fetch-mock-v10.1.1) (2024-07-23)
-
-
-### Bug Fixes
-
-* change module system declaratuions to avoid top level type: module ([ed00140](https://github.com/wheresrhys/fetch-mock/commit/ed001407792a12b5fec94013aafccbb4bbb63a87))
-
 ## [10.1.0](https://github.com/wheresrhys/fetch-mock/compare/fetch-mock-v10.0.8...fetch-mock-v10.1.0) (2024-07-18)
 
 
diff --git a/packages/fetch-mock/package.json b/packages/fetch-mock/package.json
index def74d8..78ee907 100644
--- a/packages/fetch-mock/package.json
+++ b/packages/fetch-mock/package.json
@@ -1,9 +1,8 @@
 {
   "name": "fetch-mock",
-  "version": "10.1.1",
+  "version": "10.1.0",
   "description": "Mock http requests made using fetch (or isomorphic-fetch)",
   "main": "./dist/commonjs.js",
-  "module": "./src/index.js",
   "exports": {
     "types": "./types/index.d.ts",
     "browser": "./src/index.js",
@@ -11,6 +10,7 @@
     "require": "./dist/commonjs.js"
   },
   "types": "./types/index.d.ts",
+  "type": "module",
   "repository": {
     "type": "git",
     "url": "git+https://github.com/wheresrhys/fetch-mock.git",
diff --git a/packages/fetch-mock/src/package.json b/packages/fetch-mock/src/package.json
deleted file mode 100644
index 6990891..0000000
--- a/packages/fetch-mock/src/package.json
+++ /dev/null
@@ -1,1 +0,0 @@
-{"type": "module"}


Test patch:
diff --git a/packages/core/src/__tests__/FetchMock/instance-management.test.js b/packages/core/src/__tests__/FetchMock/instance-management.test.js
index cdd6b8c..6e0145f 100644
--- a/packages/core/src/__tests__/FetchMock/instance-management.test.js
+++ b/packages/core/src/__tests__/FetchMock/instance-management.test.js
@@ -106,8 +106,6 @@ describe('instance management', () => {
 				.createInstance()
 				.route('http://a.com', 200, 'george')
 				.route('http://b.com', 200, 'best');
-			// TODO overload to also support 'george' or ['george']'
-			// Probably do the normalization at the FM level
 			fm.removeRoutes({ names: ['george'] });
 			expect(fm.router.routes[0].config.name).toBe('best');
 		});
diff --git a/packages/core/src/__tests__/Matchers/body.test.js b/packages/core/src/__tests__/Matchers/body.test.js
index adefe18..c013b1e 100644
--- a/packages/core/src/__tests__/Matchers/body.test.js
+++ b/packages/core/src/__tests__/Matchers/body.test.js
@@ -3,7 +3,6 @@ import Route from '../../Route.js';
 import Router from '../../Router.js';
 import { createCallLogFromRequest } from '../../RequestUtils.js';
 describe('body matching', () => {
-	//TODO add a test for matching an asynchronous body
 	it('should not match if no body provided in request', () => {
 		const route = new Route({ body: { foo: 'bar' }, response: 200 });
 
diff --git a/packages/core/src/__tests__/Matchers/header.js b/packages/core/src/__tests__/Matchers/header.js
index 1f64b58..8d3269c 100644
--- a/packages/core/src/__tests__/Matchers/header.js
+++ b/packages/core/src/__tests__/Matchers/header.js
@@ -62,8 +62,6 @@ describe('header matching', () => {
 			}),
 		).toBe(true);
 	});
-	// TODO Are these gonna be supported?
-	// Should we support it in the fetch-mock matcher API, even though Headers are basically sytrings
 	it('match multivalue headers', () => {
 		const route = new Route({
 			headers: { a: ['b', 'c'] },
diff --git a/packages/core/src/__tests__/Matchers/query-string.test.js b/packages/core/src/__tests__/Matchers/query-string.test.js
index 363c301..468c144 100644
--- a/packages/core/src/__tests__/Matchers/query-string.test.js
+++ b/packages/core/src/__tests__/Matchers/query-string.test.js
@@ -159,7 +159,6 @@ describe('query string matching', () => {
 		});
 	});
 
-	// TODO may need reform
 	describe('repeated query strings', () => {
 		it('match repeated query strings', () => {
 			const route = new Route({ query: { a: ['b', 'c'] }, response: 200 });
diff --git a/packages/core/src/__tests__/Matchers/route-config-object.test.js b/packages/core/src/__tests__/Matchers/route-config-object.test.js
index b9b7c4c..e6d95cd 100644
--- a/packages/core/src/__tests__/Matchers/route-config-object.test.js
+++ b/packages/core/src/__tests__/Matchers/route-config-object.test.js
@@ -42,19 +42,10 @@ describe('matcher object', () => {
 	});
 
 	// TODO this shoudl probably be an error
-	it.skip('if no url provided, match any url', () => {
-		const route = new Route({ response: 200 });
-		expect(route.matcher({ url: 'http://a.com' })).toBe(true);
-	});
-
-	//TODO be stronger on discouraging this
-	it.skip('deprecated message on using matcherFunction (prefer matcher)', () => {
-		new Route({
-			url: 'end:profile',
-			matcherFunction: (url, opts) =>
-				opts && opts.headers && opts.headers.authorized === true,
-			response: 200,
-		});
+	it('if no url provided, error', () => {
+		expect(() => new Route({ response: 200 })).toThrowError(
+			"fetch-mock: Each route must specify some criteria for matching calls to fetch. To match all calls use '*'",
+		);
 	});
 
 	it('can match Headers', () => {