@schmock/angular 1.4.0 → 1.5.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +10 -15
- package/package.json +10 -10
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EACf,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,eAAe,EACf,WAAW,EACZ,MAAM,sBAAsB,CAAC;AAQ9B,OAAO,KAAK,EACV,oBAAoB,EAGrB,MAAM,eAAe,CAAC;AA6BvB;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;IAEjB;;;OAGG;IACH,WAAW,CAAC,EAAE,OAAO,CAAC;IAEtB;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK,GAAG,CAAC;IAElE;;;;OAIG;IACH,gBAAgB,CAAC,EAAE,CAAC,OAAO,EAAE,WAAW,CAAC,GAAG,CAAC,KAAK;QAChD,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;QACjC,IAAI,CAAC,EAAE,GAAG,CAAC;QACX,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;KAChC,CAAC;IAEF;;;;;OAKG;IAC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AAE,MAAM,CAAC,CAEtD;AAED;;;GAGG;AACH,wBAAgB,SAAS,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,CAE1C;AAED;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED;;GAEG;AACH,MAAM,WAAW,iBAAiB,CAAC,CAAC;IAClC,IAAI,EAAE,CAAC,EAAE,CAAC;IACV,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC;IACd,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;;;GAQG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EACxB,KAAK,EAAE,CAAC,EAAE,EACV,OAAO,GAAE,eAAoB,GAC5B,iBAAiB,CAAC,CAAC,CAAC,CAgBtB"}
|
package/dist/index.js
CHANGED
|
@@ -17,23 +17,12 @@ import {
|
|
|
17
17
|
HttpResponse
|
|
18
18
|
} from "@angular/common/http";
|
|
19
19
|
import { Injectable } from "@angular/core";
|
|
20
|
-
import { ROUTE_NOT_FOUND_CODE } from "@schmock/core";
|
|
20
|
+
import { isHttpMethod, ROUTE_NOT_FOUND_CODE } from "@schmock/core";
|
|
21
21
|
import { Observable } from "rxjs";
|
|
22
|
-
var HTTP_METHODS = [
|
|
23
|
-
"GET",
|
|
24
|
-
"POST",
|
|
25
|
-
"PUT",
|
|
26
|
-
"DELETE",
|
|
27
|
-
"PATCH",
|
|
28
|
-
"HEAD",
|
|
29
|
-
"OPTIONS"
|
|
30
|
-
];
|
|
31
|
-
function isHttpMethod(method) {
|
|
32
|
-
return HTTP_METHODS.includes(method);
|
|
33
|
-
}
|
|
34
22
|
function toHttpMethod(method) {
|
|
35
|
-
|
|
36
|
-
|
|
23
|
+
const upper = method.toUpperCase();
|
|
24
|
+
if (isHttpMethod(upper)) {
|
|
25
|
+
return upper;
|
|
37
26
|
}
|
|
38
27
|
return "GET";
|
|
39
28
|
}
|
|
@@ -127,11 +116,14 @@ function createSchmockInterceptor(mock, options = {}) {
|
|
|
127
116
|
}
|
|
128
117
|
return new Observable((observer) => {
|
|
129
118
|
let innerSub;
|
|
119
|
+
let aborted = false;
|
|
130
120
|
mock.handle(requestData.method, requestData.path, {
|
|
131
121
|
headers: requestData.headers,
|
|
132
122
|
body: requestData.body,
|
|
133
123
|
query: requestData.query
|
|
134
124
|
}).then((schmockResponse) => {
|
|
125
|
+
if (aborted)
|
|
126
|
+
return;
|
|
135
127
|
const body = schmockResponse.body;
|
|
136
128
|
const isRouteNotFound = schmockResponse.status === 404 && body !== null && typeof body === "object" && "code" in body && body.code === ROUTE_NOT_FOUND_CODE;
|
|
137
129
|
if (isRouteNotFound && passthrough) {
|
|
@@ -177,6 +169,8 @@ function createSchmockInterceptor(mock, options = {}) {
|
|
|
177
169
|
}
|
|
178
170
|
}
|
|
179
171
|
}).catch((error) => {
|
|
172
|
+
if (aborted)
|
|
173
|
+
return;
|
|
180
174
|
let errorBody;
|
|
181
175
|
if (errorFormatter) {
|
|
182
176
|
errorBody = errorFormatter(error instanceof Error ? error : new Error(String(error)), req);
|
|
@@ -195,6 +189,7 @@ function createSchmockInterceptor(mock, options = {}) {
|
|
|
195
189
|
}));
|
|
196
190
|
});
|
|
197
191
|
return () => {
|
|
192
|
+
aborted = true;
|
|
198
193
|
innerSub?.unsubscribe();
|
|
199
194
|
};
|
|
200
195
|
});
|
package/package.json
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@schmock/angular",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.5.1",
|
|
4
4
|
"description": "Angular HTTP interceptor adapter for Schmock",
|
|
5
5
|
"type": "module",
|
|
6
|
-
"main": "dist/index.js",
|
|
7
|
-
"types": "dist/index.d.ts",
|
|
6
|
+
"main": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
10
|
"types": "./dist/index.d.ts",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"rxjs": "^7.0.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@angular/common": "^21.1.
|
|
38
|
-
"@angular/compiler": "^21.
|
|
39
|
-
"@angular/core": "^21.1.
|
|
40
|
-
"@angular/platform-browser": "^21.
|
|
41
|
-
"@angular/platform-browser-dynamic": "^21.
|
|
42
|
-
"@types/node": "^25.1
|
|
37
|
+
"@angular/common": "^21.1.3",
|
|
38
|
+
"@angular/compiler": "^21.1.3",
|
|
39
|
+
"@angular/core": "^21.1.3",
|
|
40
|
+
"@angular/platform-browser": "^21.1.3",
|
|
41
|
+
"@angular/platform-browser-dynamic": "^21.1.3",
|
|
42
|
+
"@types/node": "^25.2.1",
|
|
43
43
|
"jsdom": "^27.4.0",
|
|
44
44
|
"typescript": "^5.9.3",
|
|
45
|
-
"vitest": "^4.0.
|
|
45
|
+
"vitest": "^4.0.18",
|
|
46
46
|
"zone.js": "^0.16.0"
|
|
47
47
|
}
|
|
48
48
|
}
|