@labdigital/commercetools-mock 2.4.0 → 2.5.0
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.cjs +18 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +18 -0
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/ctMock.ts +31 -0
- package/src/services/custom-object.test.ts +17 -1
- package/src/services/customer.test.ts +20 -0
package/dist/index.cjs
CHANGED
|
@@ -7013,6 +7013,24 @@ var CommercetoolsMock = class {
|
|
|
7013
7013
|
headers: mapHeaderType(res.headers)
|
|
7014
7014
|
});
|
|
7015
7015
|
}),
|
|
7016
|
+
import_msw.http.head(`${this.options.apiHost}/*`, async ({ request }) => {
|
|
7017
|
+
const body = await request.text();
|
|
7018
|
+
const url = new URL(request.url);
|
|
7019
|
+
const headers = copyHeaders(request.headers);
|
|
7020
|
+
const res = await (0, import_light_my_request.default)(server).get(url.pathname + "?" + url.searchParams.toString()).body(body).headers(headers).end();
|
|
7021
|
+
if (res.statusCode === 200) {
|
|
7022
|
+
const parsedBody = JSON.parse(res.body);
|
|
7023
|
+
const resultCount = "count" in parsedBody ? parsedBody.count : Object.keys(parsedBody).length;
|
|
7024
|
+
return new import_msw.HttpResponse(null, {
|
|
7025
|
+
status: resultCount > 0 ? 200 : 404,
|
|
7026
|
+
headers: mapHeaderType(res.headers)
|
|
7027
|
+
});
|
|
7028
|
+
}
|
|
7029
|
+
return new import_msw.HttpResponse(null, {
|
|
7030
|
+
status: res.statusCode,
|
|
7031
|
+
headers: mapHeaderType(res.headers)
|
|
7032
|
+
});
|
|
7033
|
+
}),
|
|
7016
7034
|
import_msw.http.get(`${this.options.apiHost}/*`, async ({ request }) => {
|
|
7017
7035
|
const body = await request.text();
|
|
7018
7036
|
const url = new URL(request.url);
|