apacuana-sdk-core 0.11.0 → 0.13.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/README.md +131 -164
- package/coverage/clover.xml +338 -302
- package/coverage/coverage-final.json +9 -9
- package/coverage/lcov-report/index.html +31 -31
- package/coverage/lcov-report/src/api/certs.js.html +1 -1
- package/coverage/lcov-report/src/api/faceLiveness.js.html +34 -7
- package/coverage/lcov-report/src/api/index.html +13 -13
- package/coverage/lcov-report/src/api/revocations.js.html +50 -5
- package/coverage/lcov-report/src/api/signatures.js.html +17 -56
- package/coverage/lcov-report/src/api/users.js.html +20 -5
- package/coverage/lcov-report/src/config/index.html +1 -1
- package/coverage/lcov-report/src/config/index.js.html +1 -1
- package/coverage/lcov-report/src/errors/index.html +1 -1
- package/coverage/lcov-report/src/errors/index.js.html +8 -8
- package/coverage/lcov-report/src/index.html +13 -13
- package/coverage/lcov-report/src/index.js.html +59 -14
- package/coverage/lcov-report/src/success/index.html +1 -1
- package/coverage/lcov-report/src/success/index.js.html +5 -5
- package/coverage/lcov-report/src/utils/constant.js.html +1 -1
- package/coverage/lcov-report/src/utils/helpers.js.html +277 -16
- package/coverage/lcov-report/src/utils/httpClient.js.html +32 -17
- package/coverage/lcov-report/src/utils/index.html +22 -22
- package/coverage/lcov.info +641 -561
- package/dist/api/revocations.d.ts +6 -3
- package/dist/api/users.d.ts +16 -6
- package/dist/index.d.ts +0 -2
- package/dist/index.js +149 -147
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +149 -147
- package/dist/index.mjs.map +1 -1
- package/dist/types/faceLiveness.d.ts +6 -5
- package/dist/types/revocations.d.ts +26 -15
- package/dist/types/signatures.d.ts +73 -63
- package/dist/utils/helpers.d.ts +4 -2
- package/package.json +1 -1
- package/src/api/faceLiveness.js +13 -4
- package/src/api/revocations.js +18 -3
- package/src/api/signatures.js +8 -21
- package/src/api/users.js +8 -3
- package/src/index.js +22 -7
- package/src/types/faceLiveness.js +11 -2
- package/src/types/revocations.js +29 -9
- package/src/types/signatures.js +47 -28
- package/src/utils/helpers.js +95 -8
- package/src/utils/httpClient.js +15 -10
- package/tests/api/faceLiveness.test.js +28 -30
- package/tests/api/revocations.test.js +4 -4
- package/tests/api/signatures.test.js +73 -16
- package/tests/index.test.js +16 -8
package/tests/index.test.js
CHANGED
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// tests/index.test.js
|
|
2
2
|
import apacuana from "../src/index.js";
|
|
3
3
|
import { setConfig, getConfig } from "../src/config/index.js";
|
|
4
|
-
import { initHttpClient } from "../src/utils/httpClient.js";
|
|
4
|
+
import { initHttpClient, setAuthToken } from "../src/utils/httpClient.js";
|
|
5
5
|
import getCustomer from "../src/api/users.js";
|
|
6
|
+
import ApacuanaSuccess from "../src/success/index.js";
|
|
6
7
|
|
|
7
8
|
// Mockear todas las dependencias del index.js
|
|
8
9
|
jest.mock("../src/config/index.js", () => ({
|
|
@@ -36,8 +37,11 @@ describe("Apacuana SDK Initialization (init)", () => {
|
|
|
36
37
|
|
|
37
38
|
// Mockear la respuesta exitosa de getCustomer para la mayoría de las pruebas.
|
|
38
39
|
getCustomer.mockResolvedValue({
|
|
39
|
-
|
|
40
|
-
|
|
40
|
+
success: true,
|
|
41
|
+
data: {
|
|
42
|
+
token: "mock-session-token",
|
|
43
|
+
userData: { id: "mock-user-id" },
|
|
44
|
+
},
|
|
41
45
|
});
|
|
42
46
|
|
|
43
47
|
// Opcional: Mockear console.log para no ensuciar la consola durante las pruebas.
|
|
@@ -63,8 +67,12 @@ describe("Apacuana SDK Initialization (init)", () => {
|
|
|
63
67
|
// 3. Verificar que getCustomer fue llamado.
|
|
64
68
|
expect(getCustomer).toHaveBeenCalledWith();
|
|
65
69
|
|
|
66
|
-
// 4. Verificar que se retorna
|
|
67
|
-
expect(result).
|
|
70
|
+
// 4. Verificar que se retorna una instancia de ApacuanaSuccess al finalizar la inicialización.
|
|
71
|
+
expect(result).toBeInstanceOf(ApacuanaSuccess);
|
|
72
|
+
expect(result.data).toEqual({
|
|
73
|
+
initialized: true,
|
|
74
|
+
message: "SDK inicializado correctamente.",
|
|
75
|
+
});
|
|
68
76
|
|
|
69
77
|
// 5. Verificar que las funciones se llamaron el número correcto de veces.
|
|
70
78
|
expect(setConfig).toHaveBeenCalledTimes(2); // Una vez inicial, una vez para guardar token
|
|
@@ -113,10 +121,10 @@ describe("Apacuana SDK Initialization (init)", () => {
|
|
|
113
121
|
expect(setConfig).toHaveBeenLastCalledWith({
|
|
114
122
|
...mockConfig,
|
|
115
123
|
token: "mock-session-token",
|
|
116
|
-
userData: { id: "mock-user-id" }
|
|
124
|
+
userData: { id: "mock-user-id" },
|
|
117
125
|
});
|
|
118
126
|
|
|
119
|
-
// Verificar que
|
|
120
|
-
expect(result).
|
|
127
|
+
// Verificar que la respuesta es una instancia de ApacuanaSuccess.
|
|
128
|
+
expect(result).toBeInstanceOf(ApacuanaSuccess);
|
|
121
129
|
});
|
|
122
130
|
});
|