@jaypie/testkit 1.0.4 → 1.0.5
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +13 -0
- package/package.json +2 -1
- package/src/matchers/toBeClass.matcher.js +44 -0
- package/src/matchers.module.js +2 -0
package/README.md
CHANGED
|
@@ -214,6 +214,19 @@ test("log", () => {
|
|
|
214
214
|
});
|
|
215
215
|
```
|
|
216
216
|
|
|
217
|
+
### `sqsTestRecords(message, message, ...)` or `sqsTestRecords([...])`
|
|
218
|
+
|
|
219
|
+
Generates an event object for testing SQS Lambda functions with as many messages as provided. Note, test will accept more than ten messages, but AWS will only send ten at a time.
|
|
220
|
+
|
|
221
|
+
```javascript
|
|
222
|
+
import { sqsTestRecords } from "@jaypie/testkit";
|
|
223
|
+
|
|
224
|
+
const event = sqsTestRecords(
|
|
225
|
+
{ MessageId: "1", Body: "Hello, World!" },
|
|
226
|
+
{ MessageId: "2", Body: "Goodbye, World!" }
|
|
227
|
+
);
|
|
228
|
+
```
|
|
229
|
+
|
|
217
230
|
## 🌠 Wishlist
|
|
218
231
|
|
|
219
232
|
* matcher toBeHttpStatus
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@jaypie/testkit",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.5",
|
|
4
4
|
"author": "Finlayson Studio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -17,6 +17,7 @@
|
|
|
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:toBeClass.matcher": "vitest run ./src/matchers/__tests__/toBeClass.matcher.spec.js",
|
|
20
21
|
"test:spec:toBeJaypieError.matcher": "vitest run ./src/matchers/__tests__/toBeJaypieError.matcher.spec.js"
|
|
21
22
|
},
|
|
22
23
|
"dependencies": {
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
//
|
|
2
|
+
//
|
|
3
|
+
// Constants
|
|
4
|
+
//
|
|
5
|
+
|
|
6
|
+
//
|
|
7
|
+
//
|
|
8
|
+
// Helper Functions
|
|
9
|
+
//
|
|
10
|
+
|
|
11
|
+
//
|
|
12
|
+
//
|
|
13
|
+
// Main
|
|
14
|
+
//
|
|
15
|
+
|
|
16
|
+
const toBeClass = (received) => {
|
|
17
|
+
let pass = false;
|
|
18
|
+
if (typeof received === "function") {
|
|
19
|
+
try {
|
|
20
|
+
// eslint-disable-next-line new-cap, no-new
|
|
21
|
+
new received();
|
|
22
|
+
pass = true;
|
|
23
|
+
} catch (e) {
|
|
24
|
+
pass = false;
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
if (pass) {
|
|
28
|
+
return {
|
|
29
|
+
message: () => `expected ${received} not to be a class`,
|
|
30
|
+
pass: true,
|
|
31
|
+
};
|
|
32
|
+
}
|
|
33
|
+
return {
|
|
34
|
+
message: () => `expected ${received} to be a class`,
|
|
35
|
+
pass: false,
|
|
36
|
+
};
|
|
37
|
+
};
|
|
38
|
+
|
|
39
|
+
//
|
|
40
|
+
//
|
|
41
|
+
// Export
|
|
42
|
+
//
|
|
43
|
+
|
|
44
|
+
export default toBeClass;
|
package/src/matchers.module.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { matchers as jsonSchemaMatchers } from "jest-json-schema";
|
|
2
2
|
|
|
3
|
+
import toBeClass from "./matchers/toBeClass.matcher.js";
|
|
3
4
|
import toBeJaypieError from "./matchers/toBeJaypieError.matcher.js";
|
|
4
5
|
|
|
5
6
|
//
|
|
@@ -8,6 +9,7 @@ import toBeJaypieError from "./matchers/toBeJaypieError.matcher.js";
|
|
|
8
9
|
//
|
|
9
10
|
|
|
10
11
|
export default {
|
|
12
|
+
toBeClass,
|
|
11
13
|
toBeJaypieError,
|
|
12
14
|
toBeValidSchema: jsonSchemaMatchers.toBeValidSchema,
|
|
13
15
|
toMatchSchema: jsonSchemaMatchers.toMatchSchema,
|