@or-sdk/contacts 4.6.3 → 4.6.4
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/CHANGELOG.md +9 -0
- package/package.json +4 -5
- package/tsconfig.build.json +9 -0
- package/tsconfig.dev.json +0 -1
- package/tsconfig.esm.json +2 -3
- package/tsconfig.json +4 -5
- package/tsconfig.types.json +2 -3
- package/vitest.config.mjs +2 -1
- package/dist/cjs/__tests__/contacts-error-handling.spec.js +0 -119
- package/dist/cjs/__tests__/contacts-error-handling.spec.js.map +0 -1
- package/dist/cjs/__tests__/contacts-instance.spec.js +0 -50
- package/dist/cjs/__tests__/contacts-instance.spec.js.map +0 -1
- package/dist/cjs/__tests__/db-mismatch-callback.spec.js +0 -77
- package/dist/cjs/__tests__/db-mismatch-callback.spec.js.map +0 -1
- package/dist/cjs/__tests__/poll-migration.spec.js +0 -86
- package/dist/cjs/__tests__/poll-migration.spec.js.map +0 -1
- package/dist/cjs/__tests__/utils.spec.js +0 -81
- package/dist/cjs/__tests__/utils.spec.js.map +0 -1
- package/dist/esm/__tests__/contacts-error-handling.spec.js +0 -61
- package/dist/esm/__tests__/contacts-error-handling.spec.js.map +0 -1
- package/dist/esm/__tests__/contacts-instance.spec.js +0 -48
- package/dist/esm/__tests__/contacts-instance.spec.js.map +0 -1
- package/dist/esm/__tests__/db-mismatch-callback.spec.js +0 -39
- package/dist/esm/__tests__/db-mismatch-callback.spec.js.map +0 -1
- package/dist/esm/__tests__/poll-migration.spec.js +0 -39
- package/dist/esm/__tests__/poll-migration.spec.js.map +0 -1
- package/dist/esm/__tests__/utils.spec.js +0 -34
- package/dist/esm/__tests__/utils.spec.js.map +0 -1
- package/dist/types/__tests__/contacts-error-handling.spec.d.ts +0 -2
- package/dist/types/__tests__/contacts-error-handling.spec.d.ts.map +0 -1
- package/dist/types/__tests__/contacts-instance.spec.d.ts +0 -2
- package/dist/types/__tests__/contacts-instance.spec.d.ts.map +0 -1
- package/dist/types/__tests__/db-mismatch-callback.spec.d.ts +0 -2
- package/dist/types/__tests__/db-mismatch-callback.spec.d.ts.map +0 -1
- package/dist/types/__tests__/poll-migration.spec.d.ts +0 -2
- package/dist/types/__tests__/poll-migration.spec.d.ts.map +0 -1
- package/dist/types/__tests__/utils.spec.d.ts +0 -2
- package/dist/types/__tests__/utils.spec.d.ts.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -3,6 +3,15 @@
|
|
|
3
3
|
All notable changes to this project will be documented in this file.
|
|
4
4
|
See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
|
|
5
5
|
|
|
6
|
+
## [4.6.4](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/contacts@4.6.3...@or-sdk/contacts@4.6.4) (2025-11-04)
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
### Bug Fixes
|
|
10
|
+
|
|
11
|
+
* **base:** Fix vitest tests ([3afb8a3](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/commit/3afb8a344fc68e7e3b4ab3203eedea7a7f0b5bab))
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
|
|
6
15
|
## [4.6.3](https://gitlab.internal.onereach.io/onereach/platform/or-sdk-next/compare/@or-sdk/contacts@4.6.2...@or-sdk/contacts@4.6.3) (2025-10-14)
|
|
7
16
|
|
|
8
17
|
**Note:** Version bump only for package @or-sdk/contacts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@or-sdk/contacts",
|
|
3
|
-
"version": "4.6.
|
|
3
|
+
"version": "4.6.4",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/cjs/index.js",
|
|
6
6
|
"module": "dist/esm/index.js",
|
|
@@ -22,18 +22,17 @@
|
|
|
22
22
|
},
|
|
23
23
|
"dependencies": {
|
|
24
24
|
"@onereach/types-contacts-api": "5.40.14",
|
|
25
|
-
"@or-sdk/base": "^0.42.
|
|
25
|
+
"@or-sdk/base": "^0.42.4",
|
|
26
26
|
"agentkeepalive": "^4.5.0",
|
|
27
27
|
"uuid": "^8.3.2"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"concurrently": "9.0.1",
|
|
31
31
|
"msw": "2.8.2",
|
|
32
|
-
"typescript": "5.6.2"
|
|
33
|
-
"vitest": "^3.1.3"
|
|
32
|
+
"typescript": "5.6.2"
|
|
34
33
|
},
|
|
35
34
|
"publishConfig": {
|
|
36
35
|
"access": "public"
|
|
37
36
|
},
|
|
38
|
-
"gitHead": "
|
|
37
|
+
"gitHead": "9deea9f914551e435336bc856e77b4fdfd7bdd54"
|
|
39
38
|
}
|
package/tsconfig.dev.json
CHANGED
package/tsconfig.esm.json
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
{
|
|
2
|
-
"extends": "
|
|
2
|
+
"extends": "./tsconfig.build.json",
|
|
3
3
|
"compilerOptions": {
|
|
4
4
|
"outDir": "./dist/esm",
|
|
5
5
|
"declarationDir": "./dist/types",
|
|
6
6
|
"module": "ES6",
|
|
7
7
|
"target": "es6",
|
|
8
|
-
"rootDir": "./src",
|
|
9
8
|
"declaration": true,
|
|
10
9
|
"declarationMap": true
|
|
11
10
|
}
|
|
12
|
-
}
|
|
11
|
+
}
|
package/tsconfig.json
CHANGED
package/tsconfig.types.json
CHANGED
package/vitest.config.mjs
CHANGED
|
@@ -4,8 +4,9 @@ export default defineConfig({
|
|
|
4
4
|
test: {
|
|
5
5
|
reporters: ['junit', 'default'],
|
|
6
6
|
outputFile: 'test-results/junit.xml',
|
|
7
|
+
include: ['src/**/*.{test,spec}.ts'],
|
|
8
|
+
exclude: ['dist/**'],
|
|
7
9
|
coverage: {
|
|
8
|
-
all: true,
|
|
9
10
|
reporter: ['text', 'json', 'html', 'cobertura', 'text-summary'],
|
|
10
11
|
clean: true,
|
|
11
12
|
include: [
|
|
@@ -1,119 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var msw_1 = require("msw");
|
|
40
|
-
var node_1 = require("msw/node");
|
|
41
|
-
var vitest_1 = require("vitest");
|
|
42
|
-
var apiError_1 = require("../apiError");
|
|
43
|
-
var Contacts_1 = require("../Contacts");
|
|
44
|
-
var server = (0, node_1.setupServer)(msw_1.http.delete('https://contacts.url/contact/bad-request', function () {
|
|
45
|
-
return new msw_1.HttpResponse(JSON.stringify({ error: 'bad request' }), { status: 400 });
|
|
46
|
-
}), msw_1.http.delete('https://contacts.url/contact/non-server-error', function () {
|
|
47
|
-
throw new Error('not an axios error');
|
|
48
|
-
}));
|
|
49
|
-
var buildContactsInstance = function () {
|
|
50
|
-
return new Contacts_1.Contacts({
|
|
51
|
-
token: 'test-token',
|
|
52
|
-
contactsApiUrl: 'https://contacts.url',
|
|
53
|
-
});
|
|
54
|
-
};
|
|
55
|
-
(0, vitest_1.describe)('ContactsApi error handling', function () {
|
|
56
|
-
(0, vitest_1.beforeAll)(function () { return server.listen({ onUnhandledRequest: 'error' }); });
|
|
57
|
-
(0, vitest_1.afterEach)(function () { return server.resetHandlers(); });
|
|
58
|
-
(0, vitest_1.afterAll)(function () { return server.close(); });
|
|
59
|
-
(0, vitest_1.it)('parseError called at API call failure', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
60
|
-
var api;
|
|
61
|
-
return __generator(this, function (_a) {
|
|
62
|
-
switch (_a.label) {
|
|
63
|
-
case 0:
|
|
64
|
-
api = buildContactsInstance();
|
|
65
|
-
vitest_1.vi.spyOn(api, 'parseError');
|
|
66
|
-
return [4, (0, vitest_1.expect)(api.contactApi.deleteContact('bad-request')).rejects.toThrow()];
|
|
67
|
-
case 1:
|
|
68
|
-
_a.sent();
|
|
69
|
-
(0, vitest_1.expect)(api.parseError).toBeCalled();
|
|
70
|
-
return [2];
|
|
71
|
-
}
|
|
72
|
-
});
|
|
73
|
-
}); });
|
|
74
|
-
(0, vitest_1.it)('Axios Error is handled properly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
75
|
-
var api, e_1;
|
|
76
|
-
return __generator(this, function (_a) {
|
|
77
|
-
switch (_a.label) {
|
|
78
|
-
case 0:
|
|
79
|
-
_a.trys.push([0, 2, , 3]);
|
|
80
|
-
api = buildContactsInstance();
|
|
81
|
-
return [4, api.contactApi.deleteContact('bad-request')];
|
|
82
|
-
case 1:
|
|
83
|
-
_a.sent();
|
|
84
|
-
vitest_1.assert.fail('should not reach this line');
|
|
85
|
-
return [3, 3];
|
|
86
|
-
case 2:
|
|
87
|
-
e_1 = _a.sent();
|
|
88
|
-
(0, vitest_1.expect)(e_1).toBeInstanceOf(apiError_1.ApiError);
|
|
89
|
-
(0, vitest_1.expect)(e_1.statusCode).toBe(400);
|
|
90
|
-
(0, vitest_1.expect)(e_1.cause.response.data.error).toBe('bad request');
|
|
91
|
-
return [3, 3];
|
|
92
|
-
case 3: return [2];
|
|
93
|
-
}
|
|
94
|
-
});
|
|
95
|
-
}); });
|
|
96
|
-
(0, vitest_1.it)('Error is handled properly', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
97
|
-
var api, e_2;
|
|
98
|
-
return __generator(this, function (_a) {
|
|
99
|
-
switch (_a.label) {
|
|
100
|
-
case 0:
|
|
101
|
-
_a.trys.push([0, 2, , 3]);
|
|
102
|
-
api = buildContactsInstance();
|
|
103
|
-
return [4, api.contactApi.deleteContact('non-server-error')];
|
|
104
|
-
case 1:
|
|
105
|
-
_a.sent();
|
|
106
|
-
vitest_1.assert.fail('should not reach this line');
|
|
107
|
-
return [3, 3];
|
|
108
|
-
case 2:
|
|
109
|
-
e_2 = _a.sent();
|
|
110
|
-
(0, vitest_1.expect)(e_2).toBeInstanceOf(apiError_1.ApiError);
|
|
111
|
-
(0, vitest_1.expect)(e_2.statusCode).toBe(500);
|
|
112
|
-
(0, vitest_1.expect)(e_2.cause.response.data.message).toBe('not an axios error');
|
|
113
|
-
return [3, 3];
|
|
114
|
-
case 3: return [2];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
}); });
|
|
118
|
-
});
|
|
119
|
-
//# sourceMappingURL=contacts-error-handling.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-error-handling.spec.js","sourceRoot":"","sources":["../../../src/__tests__/contacts-error-handling.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEA,2BAAyC;AACzC,iCAAuC;AACvC,iCAA0F;AAE1F,wCAAuC;AACvC,wCAAuC;AAEvC,IAAM,MAAM,GAAG,IAAA,kBAAW,EACxB,UAAI,CAAC,MAAM,CAAC,0CAA0C,EAAE;IACtD,OAAO,IAAI,kBAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC,EACF,UAAI,CAAC,MAAM,CAAC,+CAA+C,EAAE;IAI3D,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACxC,CAAC,CAAC,CACH,CAAC;AAEF,IAAM,qBAAqB,GAAG;IAC5B,OAAO,IAAI,mBAAQ,C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,EAAE,GAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;;;;;SAEpE,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,2BAA2B,EAAE;;;;;;oBAEtB,GAAG,GAAG,qBAAqB,EAAE,CAAC;oBACpC,WAAM,GAAG,CAAC,UAAU,CAAC,aAAa,CAAC,kBAAkB,CAAC,EAAA;;oBAAtD,SAAsD,CAAC;oBACvD,eAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;;;;oBAE1C,IAAA,eAAM,EAAC,GAAC,CAAC,CAAC,cAAc,CAAC,mBAAQ,CAAC,CAAC;oBACnC,IAAA,eAAM,EAAE,GAAc,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBAC7C,IAAA,eAAM,EAAE,GAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;;;;;SAE7E,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var vitest_1 = require("vitest");
|
|
4
|
-
var api_1 = require("../api");
|
|
5
|
-
var Contacts_1 = require("../Contacts");
|
|
6
|
-
var buildContactsInstance = function () {
|
|
7
|
-
return new Contacts_1.Contacts({
|
|
8
|
-
token: 'test-token',
|
|
9
|
-
contactsApiUrl: 'https://em.url',
|
|
10
|
-
});
|
|
11
|
-
};
|
|
12
|
-
(0, vitest_1.describe)('Contacts instance', function () {
|
|
13
|
-
(0, vitest_1.it)('Contacts has contactApi service', function () {
|
|
14
|
-
var api = buildContactsInstance();
|
|
15
|
-
(0, vitest_1.expect)(api.contactApi).toBeInstanceOf(api_1.ContactApi);
|
|
16
|
-
});
|
|
17
|
-
(0, vitest_1.it)('Contacts has batchProcessApi service', function () {
|
|
18
|
-
var api = buildContactsInstance();
|
|
19
|
-
(0, vitest_1.expect)(api.batchProcessApi).toBeInstanceOf(api_1.BatchProcessApi);
|
|
20
|
-
});
|
|
21
|
-
(0, vitest_1.it)('Contacts has contactBookApi service', function () {
|
|
22
|
-
var api = buildContactsInstance();
|
|
23
|
-
(0, vitest_1.expect)(api.contactBookApi).toBeInstanceOf(api_1.ContactBookApi);
|
|
24
|
-
});
|
|
25
|
-
(0, vitest_1.it)('Contacts has fieldSchemaApi service', function () {
|
|
26
|
-
var api = buildContactsInstance();
|
|
27
|
-
(0, vitest_1.expect)(api.fieldSchemaApi).toBeInstanceOf(api_1.FieldSchemaApi);
|
|
28
|
-
});
|
|
29
|
-
(0, vitest_1.it)('Contacts has fieldSchemaApi service', function () {
|
|
30
|
-
var api = buildContactsInstance();
|
|
31
|
-
(0, vitest_1.expect)(api.fieldValueApi).toBeInstanceOf(api_1.FieldValueApi);
|
|
32
|
-
});
|
|
33
|
-
(0, vitest_1.it)('Contacts has filterApi service', function () {
|
|
34
|
-
var api = buildContactsInstance();
|
|
35
|
-
(0, vitest_1.expect)(api.filterApi).toBeInstanceOf(api_1.FilterApi);
|
|
36
|
-
});
|
|
37
|
-
(0, vitest_1.it)('Contacts has migrationsApi service', function () {
|
|
38
|
-
var api = buildContactsInstance();
|
|
39
|
-
(0, vitest_1.expect)(api.migrationsApi).toBeInstanceOf(api_1.MigrationsApi);
|
|
40
|
-
});
|
|
41
|
-
(0, vitest_1.it)('Contacts has schemaPresetApi service', function () {
|
|
42
|
-
var api = buildContactsInstance();
|
|
43
|
-
(0, vitest_1.expect)(api.schemaPresetApi).toBeInstanceOf(api_1.SchemaPresetApi);
|
|
44
|
-
});
|
|
45
|
-
(0, vitest_1.it)('Contacts has sharedBookContactPermissionApi service', function () {
|
|
46
|
-
var api = buildContactsInstance();
|
|
47
|
-
(0, vitest_1.expect)(api.sharedBookContactPermissionApi).toBeInstanceOf(api_1.SharedBookContactPermissionApi);
|
|
48
|
-
});
|
|
49
|
-
});
|
|
50
|
-
//# sourceMappingURL=contacts-instance.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-instance.spec.js","sourceRoot":"","sources":["../../../src/__tests__/contacts-instance.spec.ts"],"names":[],"mappings":";;AAAA,iCAA8C;AAE9C,8BAUgB;AAChB,wCAAuC;AAEvC,IAAM,qBAAqB,GAAG;IAC5B,OAAO,IAAI,mBAAQ,CAAC;QAClB,KAAK,EAAE,YAAY;QACnB,cAAc,EAAE,gBAAgB;KACjC,CAAC,CAAC;AACL,CAAC,CAAC;AAGF,IAAA,iBAAQ,EAAC,mBAAmB,EAAE;IAE5B,IAAA,WAAE,EAAC,iCAAiC,EAAE;QACpC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,UAAU,CAAC,CAAC,cAAc,CAAC,gBAAU,CAAC,CAAC;IACpD,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,sCAAsC,EAAE;QACzC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,qBAAe,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qCAAqC,EAAE;QACxC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,oBAAc,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qCAAqC,EAAE;QACxC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,cAAc,CAAC,CAAC,cAAc,CAAC,oBAAc,CAAC,CAAC;IAC5D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qCAAqC,EAAE;QACxC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,mBAAa,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,gCAAgC,EAAE;QACnC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,eAAS,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,oCAAoC,EAAE;QACvC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,mBAAa,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,sCAAsC,EAAE;QACzC,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,qBAAe,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,qDAAqD,EAAE;QACxD,IAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,IAAA,eAAM,EAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,cAAc,CAAC,oCAA8B,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -1,77 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var types_contacts_api_1 = require("@onereach/types-contacts-api");
|
|
40
|
-
var msw_1 = require("msw");
|
|
41
|
-
var node_1 = require("msw/node");
|
|
42
|
-
var vitest_1 = require("vitest");
|
|
43
|
-
var Contacts_1 = require("../Contacts");
|
|
44
|
-
var server = (0, node_1.setupServer)(msw_1.http.get('https://em.url/migrations/v2/status', function () {
|
|
45
|
-
return msw_1.HttpResponse.json(types_contacts_api_1.MigrationState.InProgress);
|
|
46
|
-
}));
|
|
47
|
-
var callbacks = {
|
|
48
|
-
onMismatch: function (target, origin) { return target === origin; },
|
|
49
|
-
};
|
|
50
|
-
var buildContactsInstance = function () {
|
|
51
|
-
return new Contacts_1.Contacts({
|
|
52
|
-
token: 'test-token',
|
|
53
|
-
contactsApiUrl: 'https://em.url',
|
|
54
|
-
dbVersionMismatchCallback: callbacks.onMismatch,
|
|
55
|
-
});
|
|
56
|
-
};
|
|
57
|
-
(0, vitest_1.describe)('dbVersionMismatchCallback', function () {
|
|
58
|
-
(0, vitest_1.beforeAll)(function () { return server.listen(); });
|
|
59
|
-
(0, vitest_1.afterEach)(function () { return server.resetHandlers(); });
|
|
60
|
-
(0, vitest_1.afterAll)(function () { return server.close(); });
|
|
61
|
-
(0, vitest_1.it)('dbVersionMismatchCallback is called on version mismatch', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
62
|
-
var onMismatchSpy, api;
|
|
63
|
-
return __generator(this, function (_a) {
|
|
64
|
-
switch (_a.label) {
|
|
65
|
-
case 0:
|
|
66
|
-
onMismatchSpy = vitest_1.vi.spyOn(callbacks, 'onMismatch');
|
|
67
|
-
api = buildContactsInstance();
|
|
68
|
-
return [4, api.migrationsApi.getMigrationState()];
|
|
69
|
-
case 1:
|
|
70
|
-
_a.sent();
|
|
71
|
-
(0, vitest_1.expect)(onMismatchSpy).toHaveBeenCalled();
|
|
72
|
-
return [2];
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
}); });
|
|
76
|
-
});
|
|
77
|
-
//# sourceMappingURL=db-mismatch-callback.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-mismatch-callback.spec.js","sourceRoot":"","sources":["../../../src/__tests__/db-mismatch-callback.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA8D;AAC9D,2BAAyC;AACzC,iCAAuC;AACvC,iCAAkF;AAElF,wCAAuC;AAGvC,IAAM,MAAM,GAAG,IAAA,kBAAW,EACxB,UAAI,CAAC,GAAG,CAAC,qCAAqC,EAAE;IAC9C,OAAO,kBAAY,CAAC,IAAI,CAAC,mCAAc,CAAC,UAAU,CAAC,CAAC;AACtD,CAAC,CAAC,CACH,CAAC;AAEF,IAAM,SAAS,GAAG;IAChB,UAAU,EAAE,UAAC,MAAc,EAAE,MAAc,IAAO,OAAO,MAAM,KAAK,MAAM,CAAC,CAAA,CAAC;CAC7E,CAAC;AAEF,IAAM,qBAAqB,GAAG;IAC5B,OAAO,IAAI,mBAAQ,CAAC;QAClB,KAAK,EAAE,YAAY;QACnB,cAAc,EAAE,gBAAgB;QAChC,yBAAyB,EAAE,SAAS,CAAC,UAAU;KAChD,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,IAAA,iBAAQ,EAAC,2BAA2B,EAAE;IACpC,IAAA,kBAAS,EAAC,cAAM,OAAA,MAAM,CAAC,MAAM,EAAE,EAAf,CAAe,CAAC,CAAC;IACjC,IAAA,kBAAS,EAAC,cAAM,OAAA,MAAM,CAAC,aAAa,EAAE,EAAtB,CAAsB,CAAC,CAAC;IACxC,IAAA,iBAAQ,EAAC,cAAM,OAAA,MAAM,CAAC,KAAK,EAAE,EAAd,CAAc,CAAC,CAAC;IAE/B,IAAA,WAAE,EAAC,yDAAyD,EAAE;;;;;oBACtD,aAAa,GAAG,WAAE,CAAC,KAAK,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;oBAClD,GAAG,GAAG,qBAAqB,EAAE,CAAC;oBACpC,WAAM,GAAG,CAAC,aAAa,CAAC,iBAAiB,EAAE,EAAA;;oBAA3C,SAA2C,CAAC;oBAC5C,IAAA,eAAM,EAAC,aAAa,CAAC,CAAC,gBAAgB,EAAE,CAAC;;;;SAC1C,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -1,86 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var types_contacts_api_1 = require("@onereach/types-contacts-api");
|
|
40
|
-
var msw_1 = require("msw");
|
|
41
|
-
var node_1 = require("msw/node");
|
|
42
|
-
var vitest_1 = require("vitest");
|
|
43
|
-
var Contacts_1 = require("../Contacts");
|
|
44
|
-
var server = (0, node_1.setupServer)(msw_1.http.get('https://contacts.url/migrations/launch', function () { return new msw_1.HttpResponse(null, { status: 201 }); }));
|
|
45
|
-
var buildContactsInstance = function () {
|
|
46
|
-
return new Contacts_1.Contacts({
|
|
47
|
-
token: 'test-token',
|
|
48
|
-
contactsApiUrl: 'https://contacts.url',
|
|
49
|
-
});
|
|
50
|
-
};
|
|
51
|
-
(0, vitest_1.describe)('ContactsApi error handling', function () {
|
|
52
|
-
(0, vitest_1.beforeAll)(function () { return server.listen({ onUnhandledRequest: 'error' }); });
|
|
53
|
-
(0, vitest_1.afterEach)(function () { return server.resetHandlers(); });
|
|
54
|
-
(0, vitest_1.afterAll)(function () { return server.close(); });
|
|
55
|
-
(0, vitest_1.it)('pollMigrationUntilDone returns true when migration is Done', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
56
|
-
var api, res;
|
|
57
|
-
return __generator(this, function (_a) {
|
|
58
|
-
switch (_a.label) {
|
|
59
|
-
case 0:
|
|
60
|
-
server.use(msw_1.http.get('https://contacts.url/migrations/v2/status', function () { return msw_1.HttpResponse.json(types_contacts_api_1.MigrationState.InProgress); }, { once: true }), msw_1.http.get('https://contacts.url/migrations/v2/status', function () { return msw_1.HttpResponse.json(types_contacts_api_1.MigrationState.Done); }));
|
|
61
|
-
api = buildContactsInstance();
|
|
62
|
-
return [4, api.migrationsApi.pollMigrationUntilDone(900000, 50, { debounceTimeout: 60 })];
|
|
63
|
-
case 1:
|
|
64
|
-
res = _a.sent();
|
|
65
|
-
(0, vitest_1.expect)(res).toBeTruthy();
|
|
66
|
-
return [2];
|
|
67
|
-
}
|
|
68
|
-
});
|
|
69
|
-
}); });
|
|
70
|
-
(0, vitest_1.it)('pollMigrationUntilDone returns false when timeout exceeds', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
71
|
-
var api, res;
|
|
72
|
-
return __generator(this, function (_a) {
|
|
73
|
-
switch (_a.label) {
|
|
74
|
-
case 0:
|
|
75
|
-
server.use(msw_1.http.get('https://contacts.url/migrations/v2/status', function () { return msw_1.HttpResponse.json(types_contacts_api_1.MigrationState.InProgress); }, { once: true }), msw_1.http.get('https://contacts.url/migrations/v2/status', function () { return msw_1.HttpResponse.json(types_contacts_api_1.MigrationState.Done); }));
|
|
76
|
-
api = buildContactsInstance();
|
|
77
|
-
return [4, api.migrationsApi.pollMigrationUntilDone(50, 100, { debounceTimeout: 60 })];
|
|
78
|
-
case 1:
|
|
79
|
-
res = _a.sent();
|
|
80
|
-
(0, vitest_1.expect)(res).toBeFalsy();
|
|
81
|
-
return [2];
|
|
82
|
-
}
|
|
83
|
-
});
|
|
84
|
-
}); });
|
|
85
|
-
});
|
|
86
|
-
//# sourceMappingURL=poll-migration.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-migration.spec.js","sourceRoot":"","sources":["../../../src/__tests__/poll-migration.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,mEAA8D;AAC9D,2BAAyC;AACzC,iCAAuC;AACvC,iCAA8E;AAE9E,wCAAuC;AAEvC,IAAM,MAAM,GAAG,IAAA,kBAAW,EACxB,UAAI,CAAC,GAAG,CAAC,wCAAwC,EAAE,cAAM,OAAA,IAAI,kBAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,EAAvC,CAAuC,CAAC,CAClG,CAAC;AAEF,IAAM,qBAAqB,GAAG;IAC5B,OAAO,IAAI,mBAAQ,CAAC;QAClB,KAAK,EAAE,YAAY;QACnB,cAAc,EAAE,sBAAsB;KACvC,CAAC,CAAC;AACL,CAAC,CAAC;AAEF,IAAA,iBAAQ,EAAC,4BAA4B,EAAE;IACrC,IAAA,kBAAS,EAAC,cAAM,OAAA,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EAAE,CAAC,EAA9C,CAA8C,CAAC,CAAC;IAChE,IAAA,kBAAS,EAAC,cAAM,OAAA,MAAM,CAAC,aAAa,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E,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,EAAA;;oBAAtF,GAAG,GAAG,SAAgF;oBAC5F,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;;;;SACzB,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g = Object.create((typeof Iterator === "function" ? Iterator : Object).prototype);
|
|
13
|
-
return g.next = verb(0), g["throw"] = verb(1), g["return"] = verb(2), typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
39
|
-
var vitest_1 = require("vitest");
|
|
40
|
-
var utils_1 = require("../utils");
|
|
41
|
-
(0, vitest_1.describe)('ContactsApi error handling', function () {
|
|
42
|
-
(0, vitest_1.it)('debouncePromise returns resolved value', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
43
|
-
var res;
|
|
44
|
-
return __generator(this, function (_a) {
|
|
45
|
-
switch (_a.label) {
|
|
46
|
-
case 0: return [4, (0, utils_1.debouncePromise)(function () { return new Promise(function (resolve) {
|
|
47
|
-
setTimeout(function () {
|
|
48
|
-
resolve('foo');
|
|
49
|
-
}, 1);
|
|
50
|
-
}); }, 1)];
|
|
51
|
-
case 1:
|
|
52
|
-
res = _a.sent();
|
|
53
|
-
(0, vitest_1.expect)(res).toEqual('foo');
|
|
54
|
-
return [2];
|
|
55
|
-
}
|
|
56
|
-
});
|
|
57
|
-
}); });
|
|
58
|
-
(0, vitest_1.it)('debouncePromise throws error', function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
59
|
-
var e_1;
|
|
60
|
-
return __generator(this, function (_a) {
|
|
61
|
-
switch (_a.label) {
|
|
62
|
-
case 0:
|
|
63
|
-
_a.trys.push([0, 2, , 3]);
|
|
64
|
-
return [4, (0, utils_1.debouncePromise)(function () { return new Promise(function (_, reject) {
|
|
65
|
-
setTimeout(function () {
|
|
66
|
-
reject('foo');
|
|
67
|
-
}, 1);
|
|
68
|
-
}); }, 1)];
|
|
69
|
-
case 1:
|
|
70
|
-
_a.sent();
|
|
71
|
-
return [3, 3];
|
|
72
|
-
case 2:
|
|
73
|
-
e_1 = _a.sent();
|
|
74
|
-
(0, vitest_1.expect)(e_1).toEqual('foo');
|
|
75
|
-
return [3, 3];
|
|
76
|
-
case 3: return [2];
|
|
77
|
-
}
|
|
78
|
-
});
|
|
79
|
-
}); });
|
|
80
|
-
});
|
|
81
|
-
//# sourceMappingURL=utils.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../src/__tests__/utils.spec.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,iCAA8C;AAE9C,kCAA2C;AAE3C,IAAA,iBAAQ,EAAC,4BAA4B,EAAE;IAErC,IAAA,WAAE,EAAC,wCAAwC,EAAE;;;;wBAC/B,WAAM,IAAA,uBAAe,EAAC,cAAM,OAAA,IAAI,OAAO,CAAC,UAAC,OAAO;wBAC1D,UAAU,CAAC;4BACT,OAAO,CAAC,KAAK,CAAC,CAAC;wBACjB,CAAC,EAAE,CAAC,CAAC,CAAC;oBACR,CAAC,CAAC,EAJsC,CAItC,EAAE,CAAC,CAAC,EAAA;;oBAJA,GAAG,GAAG,SAIN;oBACN,IAAA,eAAM,EAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;;;;SAC5B,CAAC,CAAC;IAEH,IAAA,WAAE,EAAC,8BAA8B,EAAE;;;;;;oBAE/B,WAAM,IAAA,uBAAe,EACnB,cAAM,OAAA,IAAI,OAAO,CAAC,UAAC,CAAC,EAAE,MAAM;4BAC1B,UAAU,CAAC;gCACT,MAAM,CAAC,KAAK,CAAC,CAAC;4BAChB,CAAC,EAAE,CAAC,CAAC,CAAC;wBACR,CAAC,CAAC,EAJI,CAIJ,EACF,CAAC,CACF,EAAA;;oBAPD,SAOC,CAAC;;;;oBAEF,IAAA,eAAM,EAAC,GAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;;;;;SAE5B,CAAC,CAAC;AAGL,CAAC,CAAC,CAAC"}
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { http, HttpResponse } from 'msw';
|
|
11
|
-
import { setupServer } from 'msw/node';
|
|
12
|
-
import { afterAll, afterEach, beforeAll, describe, expect, it, vi, assert } from 'vitest';
|
|
13
|
-
import { ApiError } from '../apiError';
|
|
14
|
-
import { Contacts } from '../Contacts';
|
|
15
|
-
const server = setupServer(http.delete('https://contacts.url/contact/bad-request', () => {
|
|
16
|
-
return new HttpResponse(JSON.stringify({ error: 'bad request' }), { status: 400 });
|
|
17
|
-
}), http.delete('https://contacts.url/contact/non-server-error', () => {
|
|
18
|
-
throw new Error('not an axios error');
|
|
19
|
-
}));
|
|
20
|
-
const buildContactsInstance = () => {
|
|
21
|
-
return new Contacts({
|
|
22
|
-
token: 'test-token',
|
|
23
|
-
contactsApiUrl: 'https://contacts.url',
|
|
24
|
-
});
|
|
25
|
-
};
|
|
26
|
-
describe('ContactsApi error handling', () => {
|
|
27
|
-
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
|
|
28
|
-
afterEach(() => server.resetHandlers());
|
|
29
|
-
afterAll(() => server.close());
|
|
30
|
-
it('parseError called at API call failure', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
31
|
-
const api = buildContactsInstance();
|
|
32
|
-
vi.spyOn(api, 'parseError');
|
|
33
|
-
yield expect(api.contactApi.deleteContact('bad-request')).rejects.toThrow();
|
|
34
|
-
expect(api.parseError).toBeCalled();
|
|
35
|
-
}));
|
|
36
|
-
it('Axios Error is handled properly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
37
|
-
try {
|
|
38
|
-
const api = buildContactsInstance();
|
|
39
|
-
yield api.contactApi.deleteContact('bad-request');
|
|
40
|
-
assert.fail('should not reach this line');
|
|
41
|
-
}
|
|
42
|
-
catch (e) {
|
|
43
|
-
expect(e).toBeInstanceOf(ApiError);
|
|
44
|
-
expect(e.statusCode).toBe(400);
|
|
45
|
-
expect(e.cause.response.data.error).toBe('bad request');
|
|
46
|
-
}
|
|
47
|
-
}));
|
|
48
|
-
it('Error is handled properly', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
49
|
-
try {
|
|
50
|
-
const api = buildContactsInstance();
|
|
51
|
-
yield api.contactApi.deleteContact('non-server-error');
|
|
52
|
-
assert.fail('should not reach this line');
|
|
53
|
-
}
|
|
54
|
-
catch (e) {
|
|
55
|
-
expect(e).toBeInstanceOf(ApiError);
|
|
56
|
-
expect(e.statusCode).toBe(500);
|
|
57
|
-
expect(e.cause.response.data.message).toBe('not an axios error');
|
|
58
|
-
}
|
|
59
|
-
}));
|
|
60
|
-
});
|
|
61
|
-
//# sourceMappingURL=contacts-error-handling.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-error-handling.spec.js","sourceRoot":"","sources":["../../../src/__tests__/contacts-error-handling.spec.ts"],"names":[],"mappings":";;;;;;;;;AAEA,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,EAAE,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAE1F,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAG,WAAW,CACxB,IAAI,CAAC,MAAM,CAAC,0CAA0C,EAAE,GAAG,EAAE;IAC3D,OAAO,IAAI,YAAY,CAAC,IAAI,CAAC,SAAS,CAAC,EAAE,KAAK,EAAE,aAAa,EAAE,CAAC,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC;AACrF,CAAC,CAAC,EACF,IAAI,CAAC,MAAM,CAAC,+CAA+C,EAAE,GAAG,EAAE;IAIhE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;AACxC,CAAC,CAAC,CACH,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,OAAO,IAAI,QAAQ,CAAC;QAClB,KAAK,EAAE,YAAY;QACnB,cAAc,EAAE,sBAAsB;KACvC,CAAC,CAAC;AACL,CAAC,CAAC;AAGF,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAC1C,SAAS,CAAC,GAAG,EAAE,CAAC,MAAM,CAAC,MAAM,CAAC,EAAE,kBAAkB,EAAE,OAAO,EA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AU,CAAC,aAAa,CAAC,kBAAkB,CAAC,CAAC;YACvD,MAAM,CAAC,IAAI,CAAC,4BAA4B,CAAC,CAAC;QAC5C,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC,CAAC,CAAC,cAAc,CAAC,QAAQ,CAAC,CAAC;YACnC,MAAM,CAAE,CAAc,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YAC7C,MAAM,CAAE,CAAS,CAAC,KAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC;QAC5E,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,48 +0,0 @@
|
|
|
1
|
-
import { describe, expect, it } from 'vitest';
|
|
2
|
-
import { BatchProcessApi, ContactApi, ContactBookApi, FieldSchemaApi, FieldValueApi, FilterApi, MigrationsApi, SchemaPresetApi, SharedBookContactPermissionApi, } from '../api';
|
|
3
|
-
import { Contacts } from '../Contacts';
|
|
4
|
-
const buildContactsInstance = () => {
|
|
5
|
-
return new Contacts({
|
|
6
|
-
token: 'test-token',
|
|
7
|
-
contactsApiUrl: 'https://em.url',
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
describe('Contacts instance', () => {
|
|
11
|
-
it('Contacts has contactApi service', () => {
|
|
12
|
-
const api = buildContactsInstance();
|
|
13
|
-
expect(api.contactApi).toBeInstanceOf(ContactApi);
|
|
14
|
-
});
|
|
15
|
-
it('Contacts has batchProcessApi service', () => {
|
|
16
|
-
const api = buildContactsInstance();
|
|
17
|
-
expect(api.batchProcessApi).toBeInstanceOf(BatchProcessApi);
|
|
18
|
-
});
|
|
19
|
-
it('Contacts has contactBookApi service', () => {
|
|
20
|
-
const api = buildContactsInstance();
|
|
21
|
-
expect(api.contactBookApi).toBeInstanceOf(ContactBookApi);
|
|
22
|
-
});
|
|
23
|
-
it('Contacts has fieldSchemaApi service', () => {
|
|
24
|
-
const api = buildContactsInstance();
|
|
25
|
-
expect(api.fieldSchemaApi).toBeInstanceOf(FieldSchemaApi);
|
|
26
|
-
});
|
|
27
|
-
it('Contacts has fieldSchemaApi service', () => {
|
|
28
|
-
const api = buildContactsInstance();
|
|
29
|
-
expect(api.fieldValueApi).toBeInstanceOf(FieldValueApi);
|
|
30
|
-
});
|
|
31
|
-
it('Contacts has filterApi service', () => {
|
|
32
|
-
const api = buildContactsInstance();
|
|
33
|
-
expect(api.filterApi).toBeInstanceOf(FilterApi);
|
|
34
|
-
});
|
|
35
|
-
it('Contacts has migrationsApi service', () => {
|
|
36
|
-
const api = buildContactsInstance();
|
|
37
|
-
expect(api.migrationsApi).toBeInstanceOf(MigrationsApi);
|
|
38
|
-
});
|
|
39
|
-
it('Contacts has schemaPresetApi service', () => {
|
|
40
|
-
const api = buildContactsInstance();
|
|
41
|
-
expect(api.schemaPresetApi).toBeInstanceOf(SchemaPresetApi);
|
|
42
|
-
});
|
|
43
|
-
it('Contacts has sharedBookContactPermissionApi service', () => {
|
|
44
|
-
const api = buildContactsInstance();
|
|
45
|
-
expect(api.sharedBookContactPermissionApi).toBeInstanceOf(SharedBookContactPermissionApi);
|
|
46
|
-
});
|
|
47
|
-
});
|
|
48
|
-
//# sourceMappingURL=contacts-instance.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-instance.spec.js","sourceRoot":"","sources":["../../../src/__tests__/contacts-instance.spec.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EACL,eAAe,EACf,UAAU,EACV,cAAc,EACd,cAAc,EACd,aAAa,EACb,SAAS,EACT,aAAa,EACb,eAAe,EACf,8BAA8B,GAC/B,MAAM,QAAQ,CAAC;AAChB,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAA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qB,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,SAAS,CAAC,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC;IAClD,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,oCAAoC,EAAE,GAAG,EAAE;QAC5C,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,aAAa,CAAC,CAAC,cAAc,CAAC,aAAa,CAAC,CAAC;IAC1D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,sCAAsC,EAAE,GAAG,EAAE;QAC9C,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,eAAe,CAAC,CAAC,cAAc,CAAC,eAAe,CAAC,CAAC;IAC9D,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qDAAqD,EAAE,GAAG,EAAE;QAC7D,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,MAAM,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAC,cAAc,CAAC,8BAA8B,CAAC,CAAC;IAC5F,CAAC,CAAC,CAAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { MigrationState } from '@onereach/types-contacts-api';
|
|
11
|
-
import { http, HttpResponse } from 'msw';
|
|
12
|
-
import { setupServer } from 'msw/node';
|
|
13
|
-
import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest';
|
|
14
|
-
import { Contacts } from '../Contacts';
|
|
15
|
-
const server = setupServer(http.get('https://em.url/migrations/v2/status', () => {
|
|
16
|
-
return HttpResponse.json(MigrationState.InProgress);
|
|
17
|
-
}));
|
|
18
|
-
const callbacks = {
|
|
19
|
-
onMismatch: (target, origin) => { return target === origin; },
|
|
20
|
-
};
|
|
21
|
-
const buildContactsInstance = () => {
|
|
22
|
-
return new Contacts({
|
|
23
|
-
token: 'test-token',
|
|
24
|
-
contactsApiUrl: 'https://em.url',
|
|
25
|
-
dbVersionMismatchCallback: callbacks.onMismatch,
|
|
26
|
-
});
|
|
27
|
-
};
|
|
28
|
-
describe('dbVersionMismatchCallback', () => {
|
|
29
|
-
beforeAll(() => server.listen());
|
|
30
|
-
afterEach(() => server.resetHandlers());
|
|
31
|
-
afterAll(() => server.close());
|
|
32
|
-
it('dbVersionMismatchCallback is called on version mismatch', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
const onMismatchSpy = vi.spyOn(callbacks, 'onMismatch');
|
|
34
|
-
const api = buildContactsInstance();
|
|
35
|
-
yield api.migrationsApi.getMigrationState();
|
|
36
|
-
expect(onMismatchSpy).toHaveBeenCalled();
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=db-mismatch-callback.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-mismatch-callback.spec.js","sourceRoot":"","sources":["../../../src/__tests__/db-mismatch-callback.spec.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE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AAC;AAEL,CAAC,CAAC,CAAC"}
|
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { MigrationState } from '@onereach/types-contacts-api';
|
|
11
|
-
import { http, HttpResponse } from 'msw';
|
|
12
|
-
import { setupServer } from 'msw/node';
|
|
13
|
-
import { afterAll, afterEach, beforeAll, describe, expect, it } from 'vitest';
|
|
14
|
-
import { Contacts } from '../Contacts';
|
|
15
|
-
const server = setupServer(http.get('https://contacts.url/migrations/launch', () => new HttpResponse(null, { status: 201 })));
|
|
16
|
-
const buildContactsInstance = () => {
|
|
17
|
-
return new Contacts({
|
|
18
|
-
token: 'test-token',
|
|
19
|
-
contactsApiUrl: 'https://contacts.url',
|
|
20
|
-
});
|
|
21
|
-
};
|
|
22
|
-
describe('ContactsApi error handling', () => {
|
|
23
|
-
beforeAll(() => server.listen({ onUnhandledRequest: 'error' }));
|
|
24
|
-
afterEach(() => server.resetHandlers());
|
|
25
|
-
afterAll(() => server.close());
|
|
26
|
-
it('pollMigrationUntilDone returns true when migration is Done', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
27
|
-
server.use(http.get('https://contacts.url/migrations/v2/status', () => HttpResponse.json(MigrationState.InProgress), { once: true }), http.get('https://contacts.url/migrations/v2/status', () => HttpResponse.json(MigrationState.Done)));
|
|
28
|
-
const api = buildContactsInstance();
|
|
29
|
-
const res = yield api.migrationsApi.pollMigrationUntilDone(900000, 50, { debounceTimeout: 60 });
|
|
30
|
-
expect(res).toBeTruthy();
|
|
31
|
-
}));
|
|
32
|
-
it('pollMigrationUntilDone returns false when timeout exceeds', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
33
|
-
server.use(http.get('https://contacts.url/migrations/v2/status', () => HttpResponse.json(MigrationState.InProgress), { once: true }), http.get('https://contacts.url/migrations/v2/status', () => HttpResponse.json(MigrationState.Done)));
|
|
34
|
-
const api = buildContactsInstance();
|
|
35
|
-
const res = yield api.migrationsApi.pollMigrationUntilDone(50, 100, { debounceTimeout: 60 });
|
|
36
|
-
expect(res).toBeFalsy();
|
|
37
|
-
}));
|
|
38
|
-
});
|
|
39
|
-
//# sourceMappingURL=poll-migration.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-migration.spec.js","sourceRoot":"","sources":["../../../src/__tests__/poll-migration.spec.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,8BAA8B,CAAC;AAC9D,OAAO,EAAE,IAAI,EAAE,YAAY,EAAE,MAAM,KAAK,CAAC;AACzC,OAAO,EAAE,WAAW,EAAE,MAAM,UAAU,CAAC;AACvC,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,MAAM,GAAG,WAAW,CACxB,IAAI,CAAC,GAAG,CAAC,wCAAwC,EAAE,GAAG,EAAE,CAAC,IAAI,YAAY,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,GAAG,EAAE,CAAC,CAAC,CAClG,CAAC;AAEF,MAAM,qBAAqB,GAAG,GAAG,EAAE;IACjC,OAAO,IAAI,QAAQ,CAAC;QAClB,KAAK,EAAE,YAAY;QACnB,cA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GAAG,EAAE,CAAC,YAAY,CAAC,IAAI,CAAC,cAAc,CAAC,IAAI,CAAC,CAC7C,CACF,CAAC;QAEF,MAAM,GAAG,GAAG,qBAAqB,EAAE,CAAC;QACpC,MAAM,GAAG,GAAG,MAAM,GAAG,CAAC,aAAa,CAAC,sBAAsB,CAAC,EAAE,EAAE,GAAG,EAAE,EAAE,eAAe,EAAE,EAAE,EAAE,CAAC,CAAC;QAC7F,MAAM,CAAC,GAAG,CAAC,CAAC,SAAS,EAAE,CAAC;IAC1B,CAAC,CAAA,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"}
|
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
import { describe, expect, it } from 'vitest';
|
|
11
|
-
import { debouncePromise } from '../utils';
|
|
12
|
-
describe('ContactsApi error handling', () => {
|
|
13
|
-
it('debouncePromise returns resolved value', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
14
|
-
const res = yield debouncePromise(() => new Promise((resolve) => {
|
|
15
|
-
setTimeout(() => {
|
|
16
|
-
resolve('foo');
|
|
17
|
-
}, 1);
|
|
18
|
-
}), 1);
|
|
19
|
-
expect(res).toEqual('foo');
|
|
20
|
-
}));
|
|
21
|
-
it('debouncePromise throws error', () => __awaiter(void 0, void 0, void 0, function* () {
|
|
22
|
-
try {
|
|
23
|
-
yield debouncePromise(() => new Promise((_, reject) => {
|
|
24
|
-
setTimeout(() => {
|
|
25
|
-
reject('foo');
|
|
26
|
-
}, 1);
|
|
27
|
-
}), 1);
|
|
28
|
-
}
|
|
29
|
-
catch (e) {
|
|
30
|
-
expect(e).toEqual('foo');
|
|
31
|
-
}
|
|
32
|
-
}));
|
|
33
|
-
});
|
|
34
|
-
//# sourceMappingURL=utils.spec.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.js","sourceRoot":"","sources":["../../../src/__tests__/utils.spec.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,EAAE,EAAE,MAAM,QAAQ,CAAC;AAE9C,OAAO,EAAE,eAAe,EAAE,MAAM,UAAU,CAAC;AAE3C,QAAQ,CAAC,4BAA4B,EAAE,GAAG,EAAE;IAE1C,EAAE,CAAC,wCAAwC,EAAE,GAAS,EAAE;QACtD,MAAM,GAAG,GAAG,MAAM,eAAe,CAAC,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE;YAC9D,UAAU,CAAC,GAAG,EAAE;gBACd,OAAO,CAAC,KAAK,CAAC,CAAC;YACjB,CAAC,EAAE,CAAC,CAAC,CAAC;QACR,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;QACP,MAAM,CAAC,GAAG,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;IAC7B,CAAC,CAAA,CAAC,CAAC;IAEH,EAAE,CAAC,8BAA8B,EAAE,GAAS,EAAE;QAC5C,IAAI,CAAC;YACH,MAAM,eAAe,CACnB,GAAG,EAAE,CAAC,IAAI,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,EAAE;gBAC9B,UAAU,CAAC,GAAG,EAAE;oBACd,MAAM,CAAC,KAAK,CAAC,CAAC;gBAChB,CAAC,EAAE,CAAC,CAAC,CAAC;YACR,CAAC,CAAC,EACF,CAAC,CACF,CAAC;QACJ,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC,CAAA,CAAC,CAAC;AAGL,CAAC,CAAC,CAAC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-error-handling.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/contacts-error-handling.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"contacts-instance.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/contacts-instance.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"db-mismatch-callback.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/db-mismatch-callback.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"poll-migration.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/poll-migration.spec.ts"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"utils.spec.d.ts","sourceRoot":"","sources":["../../../src/__tests__/utils.spec.ts"],"names":[],"mappings":""}
|