@digitraffic/common 2024.1.24-3 → 2024.3.11-1
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/__test__/api/handler-factory.test.d.mts +1 -0
- package/dist/__test__/api/handler-factory.test.mjs +43 -0
- package/dist/__test__/api/response.test.d.mts +1 -0
- package/dist/__test__/api/response.test.mjs +86 -0
- package/dist/__test__/imports.test.d.mts +1 -0
- package/dist/__test__/imports.test.mjs +332 -0
- package/dist/__test__/marine/id_utils.test.d.mts +1 -0
- package/dist/__test__/marine/id_utils.test.mjs +44 -0
- package/dist/__test__/promise/promise.test.d.mts +1 -0
- package/dist/__test__/promise/promise.test.mjs +130 -0
- package/dist/__test__/runtime/dt-logger.test.d.mts +1 -0
- package/dist/__test__/runtime/dt-logger.test.mjs +108 -0
- package/dist/__test__/secrets/secret-holder.test.d.mts +1 -0
- package/dist/__test__/secrets/secret-holder.test.mjs +86 -0
- package/dist/__test__/secrets/secret.test.d.mts +1 -0
- package/dist/__test__/secrets/secret.test.mjs +38 -0
- package/dist/__test__/test/httpserver.test.d.mts +1 -0
- package/dist/__test__/test/httpserver.test.mjs +154 -0
- package/dist/__test__/test/mock-ky.test.d.mts +1 -0
- package/dist/__test__/test/mock-ky.test.mjs +46 -0
- package/dist/__test__/types/lambda-response.test.d.mts +1 -0
- package/dist/__test__/types/lambda-response.test.mjs +58 -0
- package/dist/__test__/utils/date-utils.test.d.mts +1 -0
- package/dist/__test__/utils/date-utils.test.mjs +27 -0
- package/dist/__test__/utils/geometry.test.d.mts +1 -0
- package/dist/__test__/utils/geometry.test.mjs +24 -0
- package/dist/__test__/utils/logging.test.d.mts +1 -0
- package/dist/__test__/utils/logging.test.mjs +78 -0
- package/dist/__test__/utils/utils.test.d.mts +1 -0
- package/dist/__test__/utils/utils.test.mjs +43 -0
- package/dist/aws/infra/api/handler-factory.mjs +4 -0
- package/dist/aws/infra/api/integration.d.mts +2 -2
- package/dist/aws/infra/api/integration.mjs +4 -1
- package/dist/aws/infra/api/response.d.mts +1 -1
- package/dist/aws/infra/api/responses.d.mts +1 -1
- package/dist/aws/infra/api/responses.mjs +2 -0
- package/dist/aws/infra/api/static-integration.mjs +1 -1
- package/dist/aws/infra/canaries/canary-alarm.d.mts +1 -1
- package/dist/aws/infra/canaries/canary-alarm.mjs +2 -0
- package/dist/aws/infra/canaries/canary-parameters.mjs +1 -1
- package/dist/aws/infra/canaries/canary-role.mjs +1 -0
- package/dist/aws/infra/canaries/canary.d.mts +2 -2
- package/dist/aws/infra/canaries/canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/database-canary.mjs +2 -0
- package/dist/aws/infra/canaries/database-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/database-checker.mjs +7 -1
- package/dist/aws/infra/canaries/url-canary.d.mts +2 -2
- package/dist/aws/infra/canaries/url-canary.mjs +3 -0
- package/dist/aws/infra/canaries/url-checker.d.mts +1 -1
- package/dist/aws/infra/canaries/url-checker.mjs +4 -1
- package/dist/aws/infra/documentation.mjs +5 -1
- package/dist/aws/infra/import-util.d.mts +1 -1
- package/dist/aws/infra/import-util.mjs +4 -3
- package/dist/aws/infra/scheduler.mjs +2 -0
- package/dist/aws/infra/security-rule.d.mts +1 -1
- package/dist/aws/infra/security-rule.mjs +1 -0
- package/dist/aws/infra/sqs-integration.d.mts +1 -1
- package/dist/aws/infra/sqs-integration.mjs +3 -1
- package/dist/aws/infra/sqs-queue.d.mts +1 -1
- package/dist/aws/infra/sqs-queue.mjs +2 -1
- package/dist/aws/infra/stack/lambda-configs.d.mts +4 -4
- package/dist/aws/infra/stack/lambda-configs.mjs +4 -2
- package/dist/aws/infra/stack/monitoredfunction.d.mts +3 -3
- package/dist/aws/infra/stack/monitoredfunction.mjs +23 -18
- package/dist/aws/infra/stack/parameters.mjs +1 -0
- package/dist/aws/infra/stack/rest_apis.d.mts +2 -2
- package/dist/aws/infra/stack/rest_apis.mjs +6 -1
- package/dist/aws/infra/stack/stack-checking-aspect.d.mts +2 -2
- package/dist/aws/infra/stack/stack-checking-aspect.mjs +6 -1
- package/dist/aws/infra/stack/stack.d.mts +5 -5
- package/dist/aws/infra/stack/stack.mjs +9 -0
- package/dist/aws/infra/stack/subscription.mjs +4 -0
- package/dist/aws/infra/stacks/db-dns-stack.d.mts +1 -1
- package/dist/aws/infra/stacks/db-dns-stack.mjs +1 -0
- package/dist/aws/infra/stacks/db-proxy-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-proxy-stack.mjs +4 -2
- package/dist/aws/infra/stacks/db-stack.d.mts +3 -3
- package/dist/aws/infra/stacks/db-stack.mjs +11 -7
- package/dist/aws/infra/stacks/intra-stack-configuration.d.mts +1 -1
- package/dist/aws/infra/stacks/network-stack.d.mts +2 -2
- package/dist/aws/infra/stacks/network-stack.mjs +8 -0
- package/dist/aws/infra/usage-plans.d.mts +1 -1
- package/dist/aws/infra/usage-plans.mjs +1 -0
- package/dist/aws/runtime/apikey.d.mts +2 -2
- package/dist/aws/runtime/apikey.mjs +2 -2
- package/dist/aws/runtime/digitraffic-integration-response.d.mts +1 -1
- package/dist/aws/runtime/dt-logger.mjs +6 -2
- package/dist/aws/runtime/messaging.d.mts +2 -2
- package/dist/aws/runtime/messaging.mjs +5 -4
- package/dist/aws/runtime/s3.d.mts +4 -2
- package/dist/aws/runtime/s3.mjs +15 -10
- package/dist/aws/runtime/secrets/dbsecret.d.mts +1 -1
- package/dist/aws/runtime/secrets/proxy-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/rds-holder.mjs +1 -0
- package/dist/aws/runtime/secrets/secret-holder.d.mts +1 -1
- package/dist/aws/runtime/secrets/secret-holder.mjs +6 -1
- package/dist/aws/runtime/secrets/secret.mjs +5 -6
- package/dist/aws/types/errors.mjs +1 -0
- package/dist/aws/types/lambda-response.mjs +5 -0
- package/dist/aws/types/model-with-reference.mjs +1 -1
- package/dist/database/cached.d.mts +1 -1
- package/dist/database/database.mjs +1 -0
- package/dist/database/last-updated.d.mts +1 -1
- package/dist/test/db-testutils.d.mts +1 -1
- package/dist/test/db-testutils.mjs +1 -1
- package/dist/test/httpserver.mjs +7 -3
- package/dist/test/mock-ky.d.mts +2 -0
- package/dist/test/mock-ky.mjs +15 -0
- package/dist/test/secrets-manager.d.mts +3 -2
- package/dist/test/secrets-manager.mjs +14 -16
- package/dist/test/testutils.mjs +1 -1
- package/dist/types/http-error.mjs +1 -0
- package/dist/types/nullable.d.mts +1 -1
- package/dist/utils/api-model.d.mts +2 -2
- package/dist/utils/api-model.mjs +1 -1
- package/dist/utils/geojson-types.d.mts +1 -1
- package/dist/utils/geojson-types.mjs +4 -2
- package/dist/utils/geometry.d.mts +1 -1
- package/dist/utils/geometry.mjs +3 -0
- package/dist/utils/logging.mjs +2 -2
- package/dist/utils/retry.d.mts +2 -2
- package/dist/utils/retry.mjs +2 -2
- package/dist/utils/slack.mjs +4 -3
- package/dist/utils/utils.d.mts +2 -2
- package/package.json +25 -15
- package/src/@types/geojson-validation/index.d.mts +0 -4
- package/src/aws/infra/api/handler-factory.mts +0 -86
- package/src/aws/infra/api/integration.mts +0 -147
- package/src/aws/infra/api/response.mts +0 -165
- package/src/aws/infra/api/responses.mts +0 -127
- package/src/aws/infra/api/static-integration.mts +0 -108
- package/src/aws/infra/canaries/Synthetics.d.mts +0 -21
- package/src/aws/infra/canaries/canary-alarm.mts +0 -33
- package/src/aws/infra/canaries/canary-keys.mts +0 -3
- package/src/aws/infra/canaries/canary-parameters.mts +0 -19
- package/src/aws/infra/canaries/canary-role.mts +0 -73
- package/src/aws/infra/canaries/canary.mts +0 -44
- package/src/aws/infra/canaries/database-canary.mts +0 -98
- package/src/aws/infra/canaries/database-checker.mts +0 -163
- package/src/aws/infra/canaries/url-canary.mts +0 -98
- package/src/aws/infra/canaries/url-checker.mts +0 -388
- package/src/aws/infra/documentation.mts +0 -142
- package/src/aws/infra/import-util.mts +0 -57
- package/src/aws/infra/scheduler.mts +0 -59
- package/src/aws/infra/security-rule.mts +0 -38
- package/src/aws/infra/sqs-integration.mts +0 -106
- package/src/aws/infra/sqs-queue.mts +0 -162
- package/src/aws/infra/stack/lambda-configs.mts +0 -135
- package/src/aws/infra/stack/monitoredfunction.mts +0 -352
- package/src/aws/infra/stack/parameters.mts +0 -74
- package/src/aws/infra/stack/rest_apis.mts +0 -322
- package/src/aws/infra/stack/stack-checking-aspect.mts +0 -233
- package/src/aws/infra/stack/stack.mts +0 -144
- package/src/aws/infra/stack/subscription.mts +0 -58
- package/src/aws/infra/stacks/db-dns-stack.mts +0 -77
- package/src/aws/infra/stacks/db-proxy-stack.mts +0 -134
- package/src/aws/infra/stacks/db-stack.mts +0 -292
- package/src/aws/infra/stacks/intra-stack-configuration.mts +0 -6
- package/src/aws/infra/stacks/network-stack.mts +0 -76
- package/src/aws/infra/usage-plans.mts +0 -50
- package/src/aws/runtime/apikey.mts +0 -9
- package/src/aws/runtime/digitraffic-integration-response.mts +0 -35
- package/src/aws/runtime/dt-logger-default.mts +0 -11
- package/src/aws/runtime/dt-logger.mts +0 -184
- package/src/aws/runtime/environment.mts +0 -22
- package/src/aws/runtime/messaging.mts +0 -26
- package/src/aws/runtime/s3.mts +0 -44
- package/src/aws/runtime/secrets/dbsecret.mts +0 -31
- package/src/aws/runtime/secrets/node-ttl.d.mts +0 -12
- package/src/aws/runtime/secrets/proxy-holder.mts +0 -34
- package/src/aws/runtime/secrets/rds-holder.mts +0 -34
- package/src/aws/runtime/secrets/secret-holder.mts +0 -106
- package/src/aws/runtime/secrets/secret.mts +0 -58
- package/src/aws/types/errors.mts +0 -14
- package/src/aws/types/lambda-response.mts +0 -100
- package/src/aws/types/mediatypes.mts +0 -12
- package/src/aws/types/model-with-reference.mts +0 -8
- package/src/aws/types/proxytypes.mts +0 -27
- package/src/aws/types/tags.mts +0 -3
- package/src/database/cached.mts +0 -64
- package/src/database/database.mts +0 -107
- package/src/database/last-updated.mts +0 -103
- package/src/database/models.mts +0 -7
- package/src/index.mts +0 -2
- package/src/marine/id_utils.mts +0 -30
- package/src/marine/rtz.mts +0 -57
- package/src/test/asserter.mts +0 -58
- package/src/test/db-testutils.mts +0 -52
- package/src/test/httpserver.mts +0 -111
- package/src/test/secrets-manager.mts +0 -37
- package/src/test/testutils.mts +0 -39
- package/src/types/async-timeout-error.mts +0 -5
- package/src/types/aws-env.mts +0 -3
- package/src/types/either.mts +0 -9
- package/src/types/http-error.mts +0 -8
- package/src/types/input-error.mts +0 -2
- package/src/types/language.mts +0 -3
- package/src/types/nullable.mts +0 -21
- package/src/types/traffictype.mts +0 -8
- package/src/types/urn.mts +0 -1
- package/src/types/util-types.mts +0 -10
- package/src/types/validator.mts +0 -10
- package/src/utils/api-model.mts +0 -133
- package/src/utils/base64.mts +0 -16
- package/src/utils/date-utils.mts +0 -53
- package/src/utils/geojson-types.mts +0 -22
- package/src/utils/geometry.mts +0 -171
- package/src/utils/logging.mts +0 -75
- package/src/utils/retry.mts +0 -200
- package/src/utils/slack.mts +0 -26
- package/src/utils/utils.mts +0 -184
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,43 @@
|
|
1
|
+
import { HandlerFactory } from "../../aws/infra/api/handler-factory.mjs";
|
2
|
+
import { DtLogger } from "../../aws/runtime/dt-logger.mjs";
|
3
|
+
import { LambdaResponse } from "../../aws/types/lambda-response.mjs";
|
4
|
+
import { jest } from "@jest/globals";
|
5
|
+
const logger = new DtLogger();
|
6
|
+
describe("handler-factory tests", () => {
|
7
|
+
test("test defaults", async () => {
|
8
|
+
const factory = new HandlerFactory();
|
9
|
+
const method = jest.fn((method) => {
|
10
|
+
return method;
|
11
|
+
});
|
12
|
+
const handler = factory.createEventHandler(method, logger);
|
13
|
+
await handler({});
|
14
|
+
expect(method).toHaveBeenCalledTimes(1);
|
15
|
+
});
|
16
|
+
test("test logging", async () => {
|
17
|
+
const loggingHandler = jest.fn((method) => {
|
18
|
+
return method();
|
19
|
+
});
|
20
|
+
const factory = new HandlerFactory().withLoggingHandler(loggingHandler);
|
21
|
+
const method = jest.fn((method) => {
|
22
|
+
return method;
|
23
|
+
});
|
24
|
+
const handler = factory.createEventHandler(method, logger);
|
25
|
+
await handler({});
|
26
|
+
expect(method).toHaveBeenCalledTimes(1);
|
27
|
+
expect(loggingHandler).toHaveBeenCalledTimes(1);
|
28
|
+
});
|
29
|
+
test("test error handling", async () => {
|
30
|
+
const eh = jest.fn((method) => {
|
31
|
+
return method;
|
32
|
+
});
|
33
|
+
const factory = new HandlerFactory().withErrorHandler(eh);
|
34
|
+
const method = jest.fn(() => {
|
35
|
+
throw new Error("MAGIC");
|
36
|
+
});
|
37
|
+
const handler = factory.createEventHandler(method, logger);
|
38
|
+
await handler({});
|
39
|
+
expect(method).toHaveBeenCalledTimes(1);
|
40
|
+
expect(eh).toHaveBeenCalledTimes(1);
|
41
|
+
});
|
42
|
+
});
|
43
|
+
//# sourceMappingURL=handler-factory.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,86 @@
|
|
1
|
+
import { RESPONSE_DEFAULT_LAMBDA } from "../../aws/infra/api/response.mjs";
|
2
|
+
import etag from "etag";
|
3
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
4
|
+
//const velocity = require("velocityjs");
|
5
|
+
import velocity from "velocityjs";
|
6
|
+
const TEST_BODY = "Hello world!";
|
7
|
+
describe("response tests", () => {
|
8
|
+
function generateEtagValueFromString(body) {
|
9
|
+
return generateEtagValueFromBase64String(Buffer.from(body).toString("base64"));
|
10
|
+
}
|
11
|
+
function generateEtagValueFromBase64String(bodyBase64) {
|
12
|
+
return etag(bodyBase64);
|
13
|
+
}
|
14
|
+
function generateResponse(status, fileName, timestamp) {
|
15
|
+
// eslint-disable-next-line
|
16
|
+
const compile = new velocity.Compile(
|
17
|
+
// eslint-disable-next-line
|
18
|
+
velocity.parse(RESPONSE_DEFAULT_LAMBDA));
|
19
|
+
// eslint-disable-next-line
|
20
|
+
const output = compile.render({
|
21
|
+
input: {
|
22
|
+
path: () => ({
|
23
|
+
body: Buffer.from(TEST_BODY).toString("base64"),
|
24
|
+
status,
|
25
|
+
fileName,
|
26
|
+
timestamp: timestamp?.toUTCString(),
|
27
|
+
etag: generateEtagValueFromString(TEST_BODY),
|
28
|
+
}),
|
29
|
+
},
|
30
|
+
util: {
|
31
|
+
base64Decode: (data) => Buffer.from(data, "base64").toString(),
|
32
|
+
},
|
33
|
+
context: {
|
34
|
+
responseOverride: {
|
35
|
+
status: undefined,
|
36
|
+
header: {
|
37
|
+
"Content-Type": undefined,
|
38
|
+
"Access-Control-Allow-Origin": undefined,
|
39
|
+
ETag: undefined,
|
40
|
+
"Last-Modified": undefined,
|
41
|
+
"Content-Disposition": undefined,
|
42
|
+
},
|
43
|
+
},
|
44
|
+
},
|
45
|
+
});
|
46
|
+
// @ts-expect-error: context is not in the type definition
|
47
|
+
// eslint-disable-next-line
|
48
|
+
return [output, compile.context.context];
|
49
|
+
}
|
50
|
+
function assertOutputAndContext(output, context, status, contentType, fileName, timestamp) {
|
51
|
+
expect(output).toEqual(TEST_BODY);
|
52
|
+
expect(context).toMatchObject({
|
53
|
+
responseOverride: {
|
54
|
+
status,
|
55
|
+
header: {
|
56
|
+
"Content-Type": contentType,
|
57
|
+
"Access-Control-Allow-Origin": "*",
|
58
|
+
"Content-Disposition": fileName,
|
59
|
+
"Last-Modified": timestamp?.toUTCString(),
|
60
|
+
ETag: generateEtagValueFromString(TEST_BODY),
|
61
|
+
},
|
62
|
+
},
|
63
|
+
});
|
64
|
+
}
|
65
|
+
test("test 200", () => {
|
66
|
+
const [output, context] = generateResponse(200);
|
67
|
+
assertOutputAndContext(output, context);
|
68
|
+
});
|
69
|
+
test("test 200 - filename", () => {
|
70
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
71
|
+
const [output, context] = generateResponse(200, "test.txt");
|
72
|
+
assertOutputAndContext(output, context, undefined, undefined, 'attachment; filename="test.txt"');
|
73
|
+
});
|
74
|
+
test("test 200 - filename and timestamp", () => {
|
75
|
+
const now = new Date();
|
76
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
77
|
+
const [output, context] = generateResponse(200, "test.txt", now);
|
78
|
+
assertOutputAndContext(output, context, undefined, undefined, 'attachment; filename="test.txt"', now);
|
79
|
+
});
|
80
|
+
test("test 204", () => {
|
81
|
+
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-var-requires
|
82
|
+
const [output, context] = generateResponse(204);
|
83
|
+
assertOutputAndContext(output, context, 204, "text/plain");
|
84
|
+
});
|
85
|
+
});
|
86
|
+
//# sourceMappingURL=response.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,332 @@
|
|
1
|
+
import { expect } from "@jest/globals";
|
2
|
+
test("index import ok?", () => {
|
3
|
+
const index = import("../index.mjs");
|
4
|
+
return expect(index).resolves.toBeDefined();
|
5
|
+
});
|
6
|
+
test('database import ok?', () => {
|
7
|
+
const database = import("../database/database.mjs");
|
8
|
+
return expect(database).resolves.toBeDefined();
|
9
|
+
});
|
10
|
+
test('cached import ok?', () => {
|
11
|
+
const cached = import("../database/cached.mjs");
|
12
|
+
return expect(cached).resolves.toBeDefined();
|
13
|
+
});
|
14
|
+
test('models import ok?', () => {
|
15
|
+
const models = import("../database/models.mjs");
|
16
|
+
return expect(models).resolves.toBeDefined();
|
17
|
+
});
|
18
|
+
test('lastUpdated import ok?', () => {
|
19
|
+
const lastUpdated = import("../database/last-updated.mjs");
|
20
|
+
return expect(lastUpdated).resolves.toBeDefined();
|
21
|
+
});
|
22
|
+
test('urn import ok?', () => {
|
23
|
+
const urn = import("../types/urn.mjs");
|
24
|
+
return expect(urn).resolves.toBeDefined();
|
25
|
+
});
|
26
|
+
test('utilTypes import ok?', () => {
|
27
|
+
const utilTypes = import("../types/util-types.mjs");
|
28
|
+
return expect(utilTypes).resolves.toBeDefined();
|
29
|
+
});
|
30
|
+
test('either import ok?', () => {
|
31
|
+
const either = import("../types/either.mjs");
|
32
|
+
return expect(either).resolves.toBeDefined();
|
33
|
+
});
|
34
|
+
test('validator import ok?', () => {
|
35
|
+
const validator = import("../types/validator.mjs");
|
36
|
+
return expect(validator).resolves.toBeDefined();
|
37
|
+
});
|
38
|
+
test('nullable import ok?', () => {
|
39
|
+
const nullable = import("../types/nullable.mjs");
|
40
|
+
return expect(nullable).resolves.toBeDefined();
|
41
|
+
});
|
42
|
+
test('awsEnv import ok?', () => {
|
43
|
+
const awsEnv = import("../types/aws-env.mjs");
|
44
|
+
return expect(awsEnv).resolves.toBeDefined();
|
45
|
+
});
|
46
|
+
test('asyncTimeoutError import ok?', () => {
|
47
|
+
const asyncTimeoutError = import("../types/async-timeout-error.mjs");
|
48
|
+
return expect(asyncTimeoutError).resolves.toBeDefined();
|
49
|
+
});
|
50
|
+
test('inputError import ok?', () => {
|
51
|
+
const inputError = import("../types/input-error.mjs");
|
52
|
+
return expect(inputError).resolves.toBeDefined();
|
53
|
+
});
|
54
|
+
test('httpError import ok?', () => {
|
55
|
+
const httpError = import("../types/http-error.mjs");
|
56
|
+
return expect(httpError).resolves.toBeDefined();
|
57
|
+
});
|
58
|
+
test('language import ok?', () => {
|
59
|
+
const language = import("../types/language.mjs");
|
60
|
+
return expect(language).resolves.toBeDefined();
|
61
|
+
});
|
62
|
+
test('traffictype import ok?', () => {
|
63
|
+
const traffictype = import("../types/traffictype.mjs");
|
64
|
+
return expect(traffictype).resolves.toBeDefined();
|
65
|
+
});
|
66
|
+
test('testutils import ok?', () => {
|
67
|
+
const testutils = import("../test/testutils.mjs");
|
68
|
+
return expect(testutils).resolves.toBeDefined();
|
69
|
+
});
|
70
|
+
test('dbTestutils import ok?', () => {
|
71
|
+
const dbTestutils = import("../test/db-testutils.mjs");
|
72
|
+
return expect(dbTestutils).resolves.toBeDefined();
|
73
|
+
});
|
74
|
+
test('httpserver import ok?', () => {
|
75
|
+
const httpserver = import("../test/httpserver.mjs");
|
76
|
+
return expect(httpserver).resolves.toBeDefined();
|
77
|
+
});
|
78
|
+
test('secretsManager import ok?', () => {
|
79
|
+
const secretsManager = import("../test/secrets-manager.mjs");
|
80
|
+
return expect(secretsManager).resolves.toBeDefined();
|
81
|
+
});
|
82
|
+
test('asserter import ok?', () => {
|
83
|
+
const asserter = import("../test/asserter.mjs");
|
84
|
+
return expect(asserter).resolves.toBeDefined();
|
85
|
+
});
|
86
|
+
test('rtz import ok?', () => {
|
87
|
+
const rtz = import("../marine/rtz.mjs");
|
88
|
+
return expect(rtz).resolves.toBeDefined();
|
89
|
+
});
|
90
|
+
test('idUtils import ok?', () => {
|
91
|
+
const idUtils = import("../marine/id_utils.mjs");
|
92
|
+
return expect(idUtils).resolves.toBeDefined();
|
93
|
+
});
|
94
|
+
test('apiModel import ok?', () => {
|
95
|
+
const apiModel = import("../utils/api-model.mjs");
|
96
|
+
return expect(apiModel).resolves.toBeDefined();
|
97
|
+
});
|
98
|
+
test('logging import ok?', () => {
|
99
|
+
const logging = import("../utils/logging.mjs");
|
100
|
+
return expect(logging).resolves.toBeDefined();
|
101
|
+
});
|
102
|
+
test('base64 import ok?', () => {
|
103
|
+
const base64 = import("../utils/base64.mjs");
|
104
|
+
return expect(base64).resolves.toBeDefined();
|
105
|
+
});
|
106
|
+
test('dateUtils import ok?', () => {
|
107
|
+
const dateUtils = import("../utils/date-utils.mjs");
|
108
|
+
return expect(dateUtils).resolves.toBeDefined();
|
109
|
+
});
|
110
|
+
test('geojsonTypes import ok?', () => {
|
111
|
+
const geojsonTypes = import("../utils/geojson-types.mjs");
|
112
|
+
return expect(geojsonTypes).resolves.toBeDefined();
|
113
|
+
});
|
114
|
+
test('slack import ok?', () => {
|
115
|
+
const slack = import("../utils/slack.mjs");
|
116
|
+
return expect(slack).resolves.toBeDefined();
|
117
|
+
});
|
118
|
+
test('utils import ok?', () => {
|
119
|
+
const utils = import("../utils/utils.mjs");
|
120
|
+
return expect(utils).resolves.toBeDefined();
|
121
|
+
});
|
122
|
+
test('retry import ok?', () => {
|
123
|
+
const retry = import("../utils/retry.mjs");
|
124
|
+
return expect(retry).resolves.toBeDefined();
|
125
|
+
});
|
126
|
+
test('geometry import ok?', () => {
|
127
|
+
const geometry = import("../utils/geometry.mjs");
|
128
|
+
return expect(geometry).resolves.toBeDefined();
|
129
|
+
});
|
130
|
+
test('sqsIntegration import ok?', () => {
|
131
|
+
const sqsIntegration = import("../aws/infra/sqs-integration.mjs");
|
132
|
+
return expect(sqsIntegration).resolves.toBeDefined();
|
133
|
+
});
|
134
|
+
test('networkStack import ok?', () => {
|
135
|
+
const networkStack = import("../aws/infra/stacks/network-stack.mjs");
|
136
|
+
return expect(networkStack).resolves.toBeDefined();
|
137
|
+
});
|
138
|
+
test('dbStack import ok?', () => {
|
139
|
+
const dbStack = import("../aws/infra/stacks/db-stack.mjs");
|
140
|
+
return expect(dbStack).resolves.toBeDefined();
|
141
|
+
});
|
142
|
+
test('dbProxyStack import ok?', () => {
|
143
|
+
const dbProxyStack = import("../aws/infra/stacks/db-proxy-stack.mjs");
|
144
|
+
return expect(dbProxyStack).resolves.toBeDefined();
|
145
|
+
});
|
146
|
+
test('intraStackConfiguration import ok?', () => {
|
147
|
+
const intraStackConfiguration = import("../aws/infra/stacks/intra-stack-configuration.mjs");
|
148
|
+
return expect(intraStackConfiguration).resolves.toBeDefined();
|
149
|
+
});
|
150
|
+
test('dbDnsStack import ok?', () => {
|
151
|
+
const dbDnsStack = import("../aws/infra/stacks/db-dns-stack.mjs");
|
152
|
+
return expect(dbDnsStack).resolves.toBeDefined();
|
153
|
+
});
|
154
|
+
test('documentation import ok?', () => {
|
155
|
+
const documentation = import("../aws/infra/documentation.mjs");
|
156
|
+
return expect(documentation).resolves.toBeDefined();
|
157
|
+
});
|
158
|
+
test('usagePlans import ok?', () => {
|
159
|
+
const usagePlans = import("../aws/infra/usage-plans.mjs");
|
160
|
+
return expect(usagePlans).resolves.toBeDefined();
|
161
|
+
});
|
162
|
+
test('scheduler import ok?', () => {
|
163
|
+
const scheduler = import("../aws/infra/scheduler.mjs");
|
164
|
+
return expect(scheduler).resolves.toBeDefined();
|
165
|
+
});
|
166
|
+
test('importUtil import ok?', () => {
|
167
|
+
const importUtil = import("../aws/infra/import-util.mjs");
|
168
|
+
return expect(importUtil).resolves.toBeDefined();
|
169
|
+
});
|
170
|
+
test('sqsQueue import ok?', () => {
|
171
|
+
const sqsQueue = import("../aws/infra/sqs-queue.mjs");
|
172
|
+
return expect(sqsQueue).resolves.toBeDefined();
|
173
|
+
});
|
174
|
+
test('response import ok?', () => {
|
175
|
+
const response = import("../aws/infra/api/response.mjs");
|
176
|
+
return expect(response).resolves.toBeDefined();
|
177
|
+
});
|
178
|
+
test('staticIntegration import ok?', () => {
|
179
|
+
const staticIntegration = import("../aws/infra/api/static-integration.mjs");
|
180
|
+
return expect(staticIntegration).resolves.toBeDefined();
|
181
|
+
});
|
182
|
+
test('responses import ok?', () => {
|
183
|
+
const responses = import("../aws/infra/api/responses.mjs");
|
184
|
+
return expect(responses).resolves.toBeDefined();
|
185
|
+
});
|
186
|
+
test('handlerFactory import ok?', () => {
|
187
|
+
const handlerFactory = import("../aws/infra/api/handler-factory.mjs");
|
188
|
+
return expect(handlerFactory).resolves.toBeDefined();
|
189
|
+
});
|
190
|
+
test('integration import ok?', () => {
|
191
|
+
const integration = import("../aws/infra/api/integration.mjs");
|
192
|
+
return expect(integration).resolves.toBeDefined();
|
193
|
+
});
|
194
|
+
test('stackCheckingAspect import ok?', () => {
|
195
|
+
const stackCheckingAspect = import("../aws/infra/stack/stack-checking-aspect.mjs");
|
196
|
+
return expect(stackCheckingAspect).resolves.toBeDefined();
|
197
|
+
});
|
198
|
+
test('restApis import ok?', () => {
|
199
|
+
const restApis = import("../aws/infra/stack/rest_apis.mjs");
|
200
|
+
return expect(restApis).resolves.toBeDefined();
|
201
|
+
});
|
202
|
+
test('lambdaConfigs import ok?', () => {
|
203
|
+
const lambdaConfigs = import("../aws/infra/stack/lambda-configs.mjs");
|
204
|
+
return expect(lambdaConfigs).resolves.toBeDefined();
|
205
|
+
});
|
206
|
+
test('monitoredfunction import ok?', () => {
|
207
|
+
const monitoredfunction = import("../aws/infra/stack/monitoredfunction.mjs");
|
208
|
+
return expect(monitoredfunction).resolves.toBeDefined();
|
209
|
+
});
|
210
|
+
test('subscription import ok?', () => {
|
211
|
+
const subscription = import("../aws/infra/stack/subscription.mjs");
|
212
|
+
return expect(subscription).resolves.toBeDefined();
|
213
|
+
});
|
214
|
+
test('parameters import ok?', () => {
|
215
|
+
const parameters = import("../aws/infra/stack/parameters.mjs");
|
216
|
+
return expect(parameters).resolves.toBeDefined();
|
217
|
+
});
|
218
|
+
test('stack import ok?', () => {
|
219
|
+
const stack = import("../aws/infra/stack/stack.mjs");
|
220
|
+
return expect(stack).resolves.toBeDefined();
|
221
|
+
});
|
222
|
+
test('securityRule import ok?', () => {
|
223
|
+
const securityRule = import("../aws/infra/security-rule.mjs");
|
224
|
+
return expect(securityRule).resolves.toBeDefined();
|
225
|
+
});
|
226
|
+
test('canary import ok?', () => {
|
227
|
+
const canary = import("../aws/infra/canaries/canary.mjs");
|
228
|
+
return expect(canary).resolves.toBeDefined();
|
229
|
+
});
|
230
|
+
test('databaseCanary import ok?', () => {
|
231
|
+
const databaseCanary = import("../aws/infra/canaries/database-canary.mjs");
|
232
|
+
return expect(databaseCanary).resolves.toBeDefined();
|
233
|
+
});
|
234
|
+
test('canaryAlarm import ok?', () => {
|
235
|
+
const canaryAlarm = import("../aws/infra/canaries/canary-alarm.mjs");
|
236
|
+
return expect(canaryAlarm).resolves.toBeDefined();
|
237
|
+
});
|
238
|
+
test('canaryRole import ok?', () => {
|
239
|
+
const canaryRole = import("../aws/infra/canaries/canary-role.mjs");
|
240
|
+
return expect(canaryRole).resolves.toBeDefined();
|
241
|
+
});
|
242
|
+
test('urlCanary import ok?', () => {
|
243
|
+
const urlCanary = import("../aws/infra/canaries/url-canary.mjs");
|
244
|
+
return expect(urlCanary).resolves.toBeDefined();
|
245
|
+
});
|
246
|
+
test('canaryParameters import ok?', () => {
|
247
|
+
const canaryParameters = import("../aws/infra/canaries/canary-parameters.mjs");
|
248
|
+
return expect(canaryParameters).resolves.toBeDefined();
|
249
|
+
});
|
250
|
+
test('canaryKeys import ok?', () => {
|
251
|
+
const canaryKeys = import("../aws/infra/canaries/canary-keys.mjs");
|
252
|
+
return expect(canaryKeys).resolves.toBeDefined();
|
253
|
+
});
|
254
|
+
test('proxytypes import ok?', () => {
|
255
|
+
const proxytypes = import("../aws/types/proxytypes.mjs");
|
256
|
+
return expect(proxytypes).resolves.toBeDefined();
|
257
|
+
});
|
258
|
+
test('tags import ok?', () => {
|
259
|
+
const tags = import("../aws/types/tags.mjs");
|
260
|
+
return expect(tags).resolves.toBeDefined();
|
261
|
+
});
|
262
|
+
test('mediatypes import ok?', () => {
|
263
|
+
const mediatypes = import("../aws/types/mediatypes.mjs");
|
264
|
+
return expect(mediatypes).resolves.toBeDefined();
|
265
|
+
});
|
266
|
+
test('modelWithReference import ok?', () => {
|
267
|
+
const modelWithReference = import("../aws/types/model-with-reference.mjs");
|
268
|
+
return expect(modelWithReference).resolves.toBeDefined();
|
269
|
+
});
|
270
|
+
test('errors import ok?', () => {
|
271
|
+
const errors = import("../aws/types/errors.mjs");
|
272
|
+
return expect(errors).resolves.toBeDefined();
|
273
|
+
});
|
274
|
+
test('lambdaResponse import ok?', () => {
|
275
|
+
const lambdaResponse = import("../aws/types/lambda-response.mjs");
|
276
|
+
return expect(lambdaResponse).resolves.toBeDefined();
|
277
|
+
});
|
278
|
+
test('dtLoggerDefault import ok?', () => {
|
279
|
+
const dtLoggerDefault = import("../aws/runtime/dt-logger-default.mjs");
|
280
|
+
return expect(dtLoggerDefault).resolves.toBeDefined();
|
281
|
+
});
|
282
|
+
test('secret import ok?', () => {
|
283
|
+
const secret = import("../aws/runtime/secrets/secret.mjs");
|
284
|
+
return expect(secret).resolves.toBeDefined();
|
285
|
+
});
|
286
|
+
test('proxyHolder import ok?', () => {
|
287
|
+
const proxyHolder = import("../aws/runtime/secrets/proxy-holder.mjs");
|
288
|
+
return expect(proxyHolder).resolves.toBeDefined();
|
289
|
+
});
|
290
|
+
test('dbsecret import ok?', () => {
|
291
|
+
const dbsecret = import("../aws/runtime/secrets/dbsecret.mjs");
|
292
|
+
return expect(dbsecret).resolves.toBeDefined();
|
293
|
+
});
|
294
|
+
test('rdsHolder import ok?', () => {
|
295
|
+
const rdsHolder = import("../aws/runtime/secrets/rds-holder.mjs");
|
296
|
+
return expect(rdsHolder).resolves.toBeDefined();
|
297
|
+
});
|
298
|
+
test('secretHolder import ok?', () => {
|
299
|
+
const secretHolder = import("../aws/runtime/secrets/secret-holder.mjs");
|
300
|
+
return expect(secretHolder).resolves.toBeDefined();
|
301
|
+
});
|
302
|
+
test('dtLogger import ok?', () => {
|
303
|
+
const dtLogger = import("../aws/runtime/dt-logger.mjs");
|
304
|
+
return expect(dtLogger).resolves.toBeDefined();
|
305
|
+
});
|
306
|
+
test('s3 import ok?', () => {
|
307
|
+
const s3 = import("../aws/runtime/s3.mjs");
|
308
|
+
return expect(s3).resolves.toBeDefined();
|
309
|
+
});
|
310
|
+
test('messaging import ok?', () => {
|
311
|
+
const messaging = import("../aws/runtime/messaging.mjs");
|
312
|
+
return expect(messaging).resolves.toBeDefined();
|
313
|
+
});
|
314
|
+
test('apikey import ok?', () => {
|
315
|
+
const apikey = import("../aws/runtime/apikey.mjs");
|
316
|
+
return expect(apikey).resolves.toBeDefined();
|
317
|
+
});
|
318
|
+
test('environment import ok?', () => {
|
319
|
+
const environment = import("../aws/runtime/environment.mjs");
|
320
|
+
return expect(environment).resolves.toBeDefined();
|
321
|
+
});
|
322
|
+
test('digitrafficIntegrationResponse import ok?', () => {
|
323
|
+
const digitrafficIntegrationResponse = import("../aws/runtime/digitraffic-integration-response.mjs");
|
324
|
+
return expect(digitrafficIntegrationResponse).resolves.toBeDefined();
|
325
|
+
});
|
326
|
+
/*
|
327
|
+
* Näitä ei testata, koska ne importtaa synthetics kirjaston, jolle ei ole mitään vastinetta npm:ssä. Lambdaympäristöstä
|
328
|
+
* löytyy toi kirjasto.
|
329
|
+
*/
|
330
|
+
//const databaseChecker = import("../aws/infra/canaries/database-checker.mjs");
|
331
|
+
//const urlChecker = import("../aws/infra/canaries/url-checker.mjs");
|
332
|
+
//# sourceMappingURL=imports.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,44 @@
|
|
1
|
+
import * as IdUtils from "../../marine/id_utils.mjs";
|
2
|
+
import { getRandomNumber } from "../../test/testutils.mjs";
|
3
|
+
describe("IdUtils tests", () => {
|
4
|
+
test("isValidLOCODE - success", () => {
|
5
|
+
expect(IdUtils.isValidLOCODE("FILOL")).toBe(true);
|
6
|
+
});
|
7
|
+
test("isValidLOCODE - fail with non-finnish prefix", () => {
|
8
|
+
expect(IdUtils.isValidLOCODE("SEABS")).toBe(false);
|
9
|
+
});
|
10
|
+
test("isValidLOCODE - fail with numbers", () => {
|
11
|
+
expect(IdUtils.isValidLOCODE("FIAA1")).toBe(false);
|
12
|
+
});
|
13
|
+
test("isValidIMO - successful checksum - ship TRANSMAR", () => {
|
14
|
+
expect(IdUtils.isValidIMO(9167332)).toBe(true);
|
15
|
+
});
|
16
|
+
test("isValidIMO - successful checksum - ship ANNIKA B", () => {
|
17
|
+
expect(IdUtils.isValidIMO(9213715)).toBe(true);
|
18
|
+
});
|
19
|
+
test("isValidIMO - successful checksum - ship X PRESS ELBE", () => {
|
20
|
+
expect(IdUtils.isValidIMO(9483669)).toBe(true);
|
21
|
+
});
|
22
|
+
test("isValidIMO - successful checksum - ship SILVERFORS", () => {
|
23
|
+
expect(IdUtils.isValidIMO(8322765)).toBe(true);
|
24
|
+
});
|
25
|
+
test("isValidIMO - invalid checksum", () => {
|
26
|
+
expect(IdUtils.isValidIMO(8322766)).toBe(false);
|
27
|
+
});
|
28
|
+
test("isValidIMO - fail with number smaller than 1000000", () => {
|
29
|
+
expect(IdUtils.isValidIMO(getRandomNumber(0, 1000000 - 1))).toBe(false);
|
30
|
+
});
|
31
|
+
test("isValidIMO - fail with number larger than 9999999", () => {
|
32
|
+
expect(IdUtils.isValidIMO(getRandomNumber(9999999 + 1, 99999999))).toBe(false);
|
33
|
+
});
|
34
|
+
test("isValidMMSI - success", () => {
|
35
|
+
expect(IdUtils.isValidMMSI(230927000)).toBe(true);
|
36
|
+
});
|
37
|
+
test("isValidMMSI - fail with number smaller than 100000000", () => {
|
38
|
+
expect(IdUtils.isValidMMSI(getRandomNumber(0, 100000000 - 1))).toBe(false);
|
39
|
+
});
|
40
|
+
test("isValidMMSI - fail with number larger than 999999999", () => {
|
41
|
+
expect(IdUtils.isValidMMSI(getRandomNumber(999999999 + 1, 9999999999))).toBe(false);
|
42
|
+
});
|
43
|
+
});
|
44
|
+
//# sourceMappingURL=id_utils.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|
@@ -0,0 +1,130 @@
|
|
1
|
+
import { getRandomInteger } from "../../test/testutils.mjs";
|
2
|
+
import { retry, RetryLogError } from "../../utils/retry.mjs";
|
3
|
+
import { logger } from "../../aws/runtime/dt-logger-default.mjs";
|
4
|
+
import { jest } from '@jest/globals';
|
5
|
+
jest.useFakeTimers();
|
6
|
+
describe("Promise utils tests", () => {
|
7
|
+
test("retry - no retries", async () => {
|
8
|
+
const fn = jest.fn(() => Promise.resolve(1));
|
9
|
+
const ret = await retry(fn, 0, RetryLogError.NO_LOGGING);
|
10
|
+
expect(ret).toBe(1);
|
11
|
+
expect(fn.mock.calls.length).toBe(1);
|
12
|
+
});
|
13
|
+
test("retry - error with n+1 retries", async () => {
|
14
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
15
|
+
const retries = getRandomInteger(1, 10);
|
16
|
+
try {
|
17
|
+
await retry(fn, retries, RetryLogError.NO_LOGGING);
|
18
|
+
}
|
19
|
+
catch {
|
20
|
+
// ignore
|
21
|
+
}
|
22
|
+
finally {
|
23
|
+
expect(fn.mock.calls.length).toBe(retries + 1);
|
24
|
+
}
|
25
|
+
});
|
26
|
+
test("retry - no error with n+1 retries", async () => {
|
27
|
+
const fn = jest.fn(() => Promise.resolve(1));
|
28
|
+
const retries = getRandomInteger(1, 10);
|
29
|
+
const ret = await retry(fn, retries, RetryLogError.NO_LOGGING);
|
30
|
+
expect(ret).toBe(1);
|
31
|
+
expect(fn.mock.calls.length).toBe(1);
|
32
|
+
});
|
33
|
+
test("retry - errors with no error logging", async () => {
|
34
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
35
|
+
const consoleErrorSpy = jest
|
36
|
+
.spyOn(logger, "error");
|
37
|
+
try {
|
38
|
+
await retry(fn, getRandomInteger(0, 10), RetryLogError.NO_LOGGING);
|
39
|
+
}
|
40
|
+
catch {
|
41
|
+
// ignore
|
42
|
+
}
|
43
|
+
finally {
|
44
|
+
expect(consoleErrorSpy).toHaveBeenCalledTimes(0);
|
45
|
+
consoleErrorSpy.mockRestore();
|
46
|
+
}
|
47
|
+
});
|
48
|
+
test("retry - no retries with error logging", async () => {
|
49
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
50
|
+
const consoleErrorSpy = jest
|
51
|
+
.spyOn(logger, "error");
|
52
|
+
try {
|
53
|
+
await retry(fn, 0, RetryLogError.LOG_ALL_AS_ERRORS);
|
54
|
+
}
|
55
|
+
catch {
|
56
|
+
// ignore
|
57
|
+
}
|
58
|
+
finally {
|
59
|
+
expect(consoleErrorSpy).toHaveBeenCalledTimes(1);
|
60
|
+
consoleErrorSpy.mockRestore();
|
61
|
+
}
|
62
|
+
});
|
63
|
+
test("retry - retries with error logging", async () => {
|
64
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
65
|
+
const retries = getRandomInteger(1, 10);
|
66
|
+
const consoleErrorSpy = jest
|
67
|
+
.spyOn(logger, "error");
|
68
|
+
try {
|
69
|
+
await retry(fn, retries, RetryLogError.LOG_ALL_AS_ERRORS);
|
70
|
+
}
|
71
|
+
catch {
|
72
|
+
// ignore
|
73
|
+
}
|
74
|
+
finally {
|
75
|
+
expect(consoleErrorSpy).toHaveBeenCalledTimes(retries + 1);
|
76
|
+
consoleErrorSpy.mockRestore();
|
77
|
+
}
|
78
|
+
});
|
79
|
+
test("retry - exceeded retry count throws error", async () => {
|
80
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
81
|
+
await expect(() => retry(fn, 3, RetryLogError.LOG_ALL_AS_ERRORS)).rejects.toThrow();
|
82
|
+
});
|
83
|
+
test("retry - defaults", async () => {
|
84
|
+
const fn = jest.fn(() => Promise.reject("error"));
|
85
|
+
const consoleErrorSpy = jest
|
86
|
+
.spyOn(logger, "error");
|
87
|
+
try {
|
88
|
+
await retry(fn);
|
89
|
+
}
|
90
|
+
catch {
|
91
|
+
// ignore
|
92
|
+
}
|
93
|
+
finally {
|
94
|
+
expect(fn.mock.calls.length).toBe(3 + 1);
|
95
|
+
expect(consoleErrorSpy).toHaveBeenCalledTimes(1); // last retry
|
96
|
+
}
|
97
|
+
});
|
98
|
+
test("retry - NaN throws error", async () => {
|
99
|
+
const fn = jest.fn(() => Promise.resolve(NaN));
|
100
|
+
await expect(() => retry(fn, NaN, RetryLogError.NO_LOGGING)).rejects.toThrow();
|
101
|
+
});
|
102
|
+
test("retry - Infinity throws error", async () => {
|
103
|
+
const fn = jest.fn(() => Promise.resolve(NaN));
|
104
|
+
await expect(() => retry(fn, Infinity, RetryLogError.NO_LOGGING)).rejects.toThrow();
|
105
|
+
});
|
106
|
+
test("retry - exceeded maximum retry count throws error", async () => {
|
107
|
+
const fn = jest.fn(() => Promise.resolve(NaN));
|
108
|
+
await expect(() => retry(fn, getRandomInteger(101, 1000000), RetryLogError.NO_LOGGING)).rejects.toThrow();
|
109
|
+
});
|
110
|
+
test("retry - use without mocks without retry", async () => {
|
111
|
+
const val = 1;
|
112
|
+
const fn = () => Promise.resolve(val);
|
113
|
+
const ret = await retry(fn);
|
114
|
+
expect(ret).toBe(val);
|
115
|
+
});
|
116
|
+
test("retry - use without mocks with retry", async () => {
|
117
|
+
let i = 0;
|
118
|
+
const val = 1;
|
119
|
+
const fn = () => {
|
120
|
+
if (i < 3) {
|
121
|
+
i++;
|
122
|
+
throw new Error("not yet");
|
123
|
+
}
|
124
|
+
return Promise.resolve(val);
|
125
|
+
};
|
126
|
+
const ret = await retry(fn);
|
127
|
+
expect(ret).toBe(val);
|
128
|
+
});
|
129
|
+
});
|
130
|
+
//# sourceMappingURL=promise.test.mjs.map
|
@@ -0,0 +1 @@
|
|
1
|
+
export {};
|