@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.js
CHANGED
|
@@ -6976,6 +6976,24 @@ var CommercetoolsMock = class {
|
|
|
6976
6976
|
headers: mapHeaderType(res.headers)
|
|
6977
6977
|
});
|
|
6978
6978
|
}),
|
|
6979
|
+
http.head(`${this.options.apiHost}/*`, async ({ request }) => {
|
|
6980
|
+
const body = await request.text();
|
|
6981
|
+
const url = new URL(request.url);
|
|
6982
|
+
const headers = copyHeaders(request.headers);
|
|
6983
|
+
const res = await inject(server).get(url.pathname + "?" + url.searchParams.toString()).body(body).headers(headers).end();
|
|
6984
|
+
if (res.statusCode === 200) {
|
|
6985
|
+
const parsedBody = JSON.parse(res.body);
|
|
6986
|
+
const resultCount = "count" in parsedBody ? parsedBody.count : Object.keys(parsedBody).length;
|
|
6987
|
+
return new HttpResponse(null, {
|
|
6988
|
+
status: resultCount > 0 ? 200 : 404,
|
|
6989
|
+
headers: mapHeaderType(res.headers)
|
|
6990
|
+
});
|
|
6991
|
+
}
|
|
6992
|
+
return new HttpResponse(null, {
|
|
6993
|
+
status: res.statusCode,
|
|
6994
|
+
headers: mapHeaderType(res.headers)
|
|
6995
|
+
});
|
|
6996
|
+
}),
|
|
6979
6997
|
http.get(`${this.options.apiHost}/*`, async ({ request }) => {
|
|
6980
6998
|
const body = await request.text();
|
|
6981
6999
|
const url = new URL(request.url);
|