@empathyco/x-adapter 8.1.0-alpha.12 → 8.1.0-alpha.13
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/README.md +2 -2
- package/dist/cjs/http-clients/__mocks__/fetch.mock.js +3 -2
- package/dist/cjs/http-clients/__mocks__/fetch.mock.js.map +1 -1
- package/dist/esm/http-clients/__mocks__/fetch.mock.js +3 -2
- package/dist/esm/http-clients/__mocks__/fetch.mock.js.map +1 -1
- package/dist/types/http-clients/__mocks__/fetch.mock.d.ts +3 -3
- package/package.json +11 -11
package/README.md
CHANGED
|
@@ -14,7 +14,7 @@ Some features that it provides:
|
|
|
14
14
|
## Tech Stack
|
|
15
15
|
|
|
16
16
|
[](https://www.typescriptlang.org/)
|
|
17
|
-
[](https://vitest.dev/)
|
|
18
18
|
|
|
19
19
|
<br>
|
|
20
20
|
|
|
@@ -668,7 +668,7 @@ needs.
|
|
|
668
668
|
|
|
669
669
|
## Test
|
|
670
670
|
|
|
671
|
-
**Empathy Adapter** features are tested using [
|
|
671
|
+
**Empathy Adapter** features are tested using [Vitest](https://vitest.dev/). You will find a
|
|
672
672
|
`__tests__` folder inside each of the project's sections.
|
|
673
673
|
|
|
674
674
|
```
|
|
@@ -2,8 +2,9 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.koFetchMock = exports.okFetchMock = void 0;
|
|
4
4
|
exports.fetchMock = fetchMock;
|
|
5
|
-
|
|
6
|
-
exports.
|
|
5
|
+
const vitest_1 = require("vitest");
|
|
6
|
+
exports.okFetchMock = vitest_1.vi.fn(fetchMock({}));
|
|
7
|
+
exports.koFetchMock = vitest_1.vi.fn(async () => Promise.resolve({
|
|
7
8
|
ok: false,
|
|
8
9
|
json: async () => Promise.resolve({}),
|
|
9
10
|
status: 500,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.mock.js","sourceRoot":"","sources":["../../../../src/http-clients/__mocks__/fetch.mock.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"fetch.mock.js","sourceRoot":"","sources":["../../../../src/http-clients/__mocks__/fetch.mock.ts"],"names":[],"mappings":";;;AAmBA,8BAmBC;AAtCD,mCAA2B;AACd,QAAA,WAAW,GAAG,WAAE,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AAElC,QAAA,WAAW,GAAG,WAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAC1C,OAAO,CAAC,OAAO,CAAC;IACd,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IACrC,MAAM,EAAE,GAAG;IACX,UAAU,EAAE,kBAAkB;CAC/B,CAAC,CACH,CAAA;AACD;;;;;;;GAOG;AACH,SAAgB,SAAS,CACvB,QAAiB;IAEjB,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAChC,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC/C,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAA;gBACnD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC;wBACN,EAAE,EAAE,IAAI;wBACR,MAAM,EAAE,GAAG;wBACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;wBAC3C,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;qBAChD,CAAC,CAAA;gBAChB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { vi } from 'vitest'\nexport const okFetchMock = vi.fn(fetchMock({}))\n\nexport const koFetchMock = vi.fn(async () =>\n Promise.resolve({\n ok: false,\n json: async () => Promise.resolve({}),\n status: 500,\n statusText: 'Unexpected error',\n }),\n)\n/**\n * The `fetchMock()` method mocks a `fetch` API call.\n *\n * @param response - The expected response resolved by calling `fetch()`.\n * @returns A Promise object.\n *\n * @internal\n */\nexport function fetchMock(\n response: unknown,\n): (url: string, params: RequestInit) => Promise<Response> {\n return async (_url, { signal }) => {\n return new Promise<Response>((resolve, reject) => {\n setTimeout(() => {\n if (signal?.aborted) {\n reject(new DOMException('Aborted', 'AbortError'))\n } else {\n resolve({\n ok: true,\n status: 200,\n json: async () => Promise.resolve(response),\n text: async () => Promise.resolve(JSON.stringify(response)),\n } as Response)\n }\n })\n })\n }\n}\n"]}
|
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
|
|
2
|
-
export const
|
|
1
|
+
import { vi } from 'vitest';
|
|
2
|
+
export const okFetchMock = vi.fn(fetchMock({}));
|
|
3
|
+
export const koFetchMock = vi.fn(async () => Promise.resolve({
|
|
3
4
|
ok: false,
|
|
4
5
|
json: async () => Promise.resolve({}),
|
|
5
6
|
status: 500,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetch.mock.js","sourceRoot":"","sources":["../../../../src/http-clients/__mocks__/fetch.mock.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,WAAW,GAAG,
|
|
1
|
+
{"version":3,"file":"fetch.mock.js","sourceRoot":"","sources":["../../../../src/http-clients/__mocks__/fetch.mock.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAA;AAC3B,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,CAAC,CAAA;AAE/C,MAAM,CAAC,MAAM,WAAW,GAAG,EAAE,CAAC,EAAE,CAAC,KAAK,IAAI,EAAE,CAC1C,OAAO,CAAC,OAAO,CAAC;IACd,EAAE,EAAE,KAAK;IACT,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;IACrC,MAAM,EAAE,GAAG;IACX,UAAU,EAAE,kBAAkB;CAC/B,CAAC,CACH,CAAA;AACD;;;;;;;GAOG;AACH,MAAM,UAAU,SAAS,CACvB,QAAiB;IAEjB,OAAO,KAAK,EAAE,IAAI,EAAE,EAAE,MAAM,EAAE,EAAE,EAAE;QAChC,OAAO,IAAI,OAAO,CAAW,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;YAC/C,UAAU,CAAC,GAAG,EAAE;gBACd,IAAI,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,OAAO,EAAE,CAAC;oBACpB,MAAM,CAAC,IAAI,YAAY,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC,CAAA;gBACnD,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC;wBACN,EAAE,EAAE,IAAI;wBACR,MAAM,EAAE,GAAG;wBACX,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,QAAQ,CAAC;wBAC3C,IAAI,EAAE,KAAK,IAAI,EAAE,CAAC,OAAO,CAAC,OAAO,CAAC,IAAI,CAAC,SAAS,CAAC,QAAQ,CAAC,CAAC;qBAChD,CAAC,CAAA;gBAChB,CAAC;YACH,CAAC,CAAC,CAAA;QACJ,CAAC,CAAC,CAAA;IACJ,CAAC,CAAA;AACH,CAAC","sourcesContent":["import { vi } from 'vitest'\nexport const okFetchMock = vi.fn(fetchMock({}))\n\nexport const koFetchMock = vi.fn(async () =>\n Promise.resolve({\n ok: false,\n json: async () => Promise.resolve({}),\n status: 500,\n statusText: 'Unexpected error',\n }),\n)\n/**\n * The `fetchMock()` method mocks a `fetch` API call.\n *\n * @param response - The expected response resolved by calling `fetch()`.\n * @returns A Promise object.\n *\n * @internal\n */\nexport function fetchMock(\n response: unknown,\n): (url: string, params: RequestInit) => Promise<Response> {\n return async (_url, { signal }) => {\n return new Promise<Response>((resolve, reject) => {\n setTimeout(() => {\n if (signal?.aborted) {\n reject(new DOMException('Aborted', 'AbortError'))\n } else {\n resolve({\n ok: true,\n status: 200,\n json: async () => Promise.resolve(response),\n text: async () => Promise.resolve(JSON.stringify(response)),\n } as Response)\n }\n })\n })\n }\n}\n"]}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export declare const okFetchMock:
|
|
2
|
-
export declare const koFetchMock:
|
|
1
|
+
export declare const okFetchMock: import("vitest").Mock<(url: string, params: RequestInit) => Promise<Response>>;
|
|
2
|
+
export declare const koFetchMock: import("vitest").Mock<() => Promise<{
|
|
3
3
|
ok: boolean;
|
|
4
4
|
json: () => Promise<{}>;
|
|
5
5
|
status: number;
|
|
6
6
|
statusText: string;
|
|
7
|
-
}
|
|
7
|
+
}>>;
|
|
8
8
|
/**
|
|
9
9
|
* The `fetchMock()` method mocks a `fetch` API call.
|
|
10
10
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@empathyco/x-adapter",
|
|
3
|
-
"version": "8.1.0-alpha.
|
|
3
|
+
"version": "8.1.0-alpha.13",
|
|
4
4
|
"description": "A utils library to create a client for any API",
|
|
5
5
|
"author": "Empathy Systems Corporation S.L.",
|
|
6
6
|
"license": "Apache-2.0",
|
|
@@ -36,26 +36,26 @@
|
|
|
36
36
|
"lint:inspect": "eslint --inspect-config .",
|
|
37
37
|
"format": "prettier --write .",
|
|
38
38
|
"format:check": "prettier --check .",
|
|
39
|
-
"test": "
|
|
40
|
-
"test:unit": "
|
|
39
|
+
"test": "vitest run",
|
|
40
|
+
"test:unit": "vitest run",
|
|
41
|
+
"test:unit-coverage": "vitest run --coverage",
|
|
42
|
+
"test:unit-watch": "vitest",
|
|
41
43
|
"prepublishOnly": "pnpm run build"
|
|
42
44
|
},
|
|
43
45
|
"dependencies": {
|
|
44
46
|
"@empathyco/x-deep-merge": "2.0.3-alpha.12",
|
|
45
|
-
"@empathyco/x-utils": "1.0.3-alpha.11"
|
|
46
|
-
"tslib": "~2.8.1"
|
|
47
|
+
"@empathyco/x-utils": "1.0.3-alpha.11"
|
|
47
48
|
},
|
|
48
49
|
"devDependencies": {
|
|
49
|
-
"@
|
|
50
|
+
"@vitest/coverage-v8": "4.0.18",
|
|
50
51
|
"concurrently": "8.2.2",
|
|
51
|
-
"
|
|
52
|
-
"jest-environment-jsdom": "29.7.0",
|
|
52
|
+
"jsdom": "28.1.0",
|
|
53
53
|
"rimraf": "3.0.2",
|
|
54
|
-
"
|
|
55
|
-
"
|
|
54
|
+
"typescript": "5.9.3",
|
|
55
|
+
"vitest": "4.0.18"
|
|
56
56
|
},
|
|
57
57
|
"publishConfig": {
|
|
58
58
|
"access": "public"
|
|
59
59
|
},
|
|
60
|
-
"gitHead": "
|
|
60
|
+
"gitHead": "00d059cd47fd79a87472fe30e98c6cac5aeb41fe"
|
|
61
61
|
}
|