@jaypie/testkit 1.0.8 → 1.0.10
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/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/testkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.10",
|
|
4
4
|
"author": "Finlayson Studio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -17,12 +17,14 @@
|
|
|
17
17
|
"test:spec:matchers.module": "vitest run ./src/__tests__/matchers.module.spec.js",
|
|
18
18
|
"test:spec:mockLog.module": "vitest run ./src/__tests__/mockLog.module.spec.js",
|
|
19
19
|
"test:spec:sqsTestRecords.function": "vitest run ./src/__tests__/sqsTestRecords.function.spec.js",
|
|
20
|
+
"test:spec:toBeCalledWithInitialParams.matcher": "vitest run ./src/matchers/__tests__/toBeCalledWithInitialParams.matcher.spec.js",
|
|
20
21
|
"test:spec:toBeClass.matcher": "vitest run ./src/matchers/__tests__/toBeClass.matcher.spec.js",
|
|
21
22
|
"test:spec:toBeJaypieError.matcher": "vitest run ./src/matchers/__tests__/toBeJaypieError.matcher.spec.js"
|
|
22
23
|
},
|
|
23
24
|
"dependencies": {
|
|
24
|
-
"@jaypie/core": "^1.0.
|
|
25
|
+
"@jaypie/core": "^1.0.13",
|
|
25
26
|
"jest-json-schema": "^6.1.0",
|
|
27
|
+
"lodash.isequal": "^4.5.0",
|
|
26
28
|
"uuid": "^9.0.1"
|
|
27
29
|
},
|
|
28
30
|
"devDependencies": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
import isEqual from "lodash.isequal";
|
|
2
|
+
|
|
3
|
+
//
|
|
4
|
+
//
|
|
5
|
+
// Main
|
|
6
|
+
//
|
|
7
|
+
|
|
8
|
+
export default (received, ...passed) => {
|
|
9
|
+
let pass;
|
|
10
|
+
|
|
11
|
+
if (!received || typeof received !== "function" || !received.mock) {
|
|
12
|
+
return {
|
|
13
|
+
message: () =>
|
|
14
|
+
`Expectation \`toBeCalledWithInitialParams\` expected a mock function`,
|
|
15
|
+
pass: false,
|
|
16
|
+
};
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
received.mock.calls.forEach((call) => {
|
|
20
|
+
if (call.length >= passed.length) {
|
|
21
|
+
let matching = true;
|
|
22
|
+
for (let i = 0; i < passed.length && matching; i += 1) {
|
|
23
|
+
if (!isEqual(passed[i], call[i])) matching = false;
|
|
24
|
+
}
|
|
25
|
+
pass = pass || matching;
|
|
26
|
+
}
|
|
27
|
+
});
|
|
28
|
+
|
|
29
|
+
if (pass === undefined) pass = false;
|
|
30
|
+
|
|
31
|
+
if (pass) {
|
|
32
|
+
return {
|
|
33
|
+
message: () =>
|
|
34
|
+
`Expectation \`toBeCalledWithInitialParams\` expected call beginning with [${passed},...]`,
|
|
35
|
+
pass: true,
|
|
36
|
+
};
|
|
37
|
+
} else {
|
|
38
|
+
return {
|
|
39
|
+
message: () =>
|
|
40
|
+
`Expectation \`not.toBeCalledWithInitialParams\` did not expect call beginning with [${passed},...]`,
|
|
41
|
+
pass: false,
|
|
42
|
+
};
|
|
43
|
+
}
|
|
44
|
+
};
|
package/src/matchers.module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { matchers as jsonSchemaMatchers } from "jest-json-schema";
|
|
2
2
|
|
|
3
|
+
import toBeCalledWithInitialParams from "./matchers/toBeCalledWithInitialParams.matcher.js";
|
|
3
4
|
import toBeClass from "./matchers/toBeClass.matcher.js";
|
|
4
5
|
import toBeJaypieError from "./matchers/toBeJaypieError.matcher.js";
|
|
5
6
|
|
|
@@ -9,6 +10,7 @@ import toBeJaypieError from "./matchers/toBeJaypieError.matcher.js";
|
|
|
9
10
|
//
|
|
10
11
|
|
|
11
12
|
export default {
|
|
13
|
+
toBeCalledWithInitialParams,
|
|
12
14
|
toBeClass,
|
|
13
15
|
toBeJaypieError,
|
|
14
16
|
toBeValidSchema: jsonSchemaMatchers.toBeValidSchema,
|