@jaypie/testkit 1.0.2 → 1.0.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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jaypie/testkit",
3
- "version": "1.0.2",
3
+ "version": "1.0.4",
4
4
  "author": "Finlayson Studio",
5
5
  "type": "module",
6
6
  "main": "src/index.js",
@@ -16,13 +16,14 @@
16
16
  "test:spec:jsonApiSchema.module": "vitest run ./src/__tests__/jsonApiSchema.module.spec.js",
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
+ "test:spec:sqsTestRecords.function": "vitest run ./src/__tests__/sqsTestRecords.function.spec.js",
19
20
  "test:spec:toBeJaypieError.matcher": "vitest run ./src/matchers/__tests__/toBeJaypieError.matcher.spec.js"
20
21
  },
21
22
  "dependencies": {
23
+ "@jaypie/core": "^1.0.2",
22
24
  "jest-json-schema": "^6.1.0"
23
25
  },
24
26
  "devDependencies": {
25
- "@jaypie/core": "^0.3.7",
26
27
  "eslint": "^8.57.0",
27
28
  "eslint-config-prettier": "^9.1.0",
28
29
  "eslint-plugin-import": "^2.29.1",
package/src/index.js CHANGED
@@ -8,3 +8,4 @@ export { LOG } from "@jaypie/core";
8
8
  export { jsonApiErrorSchema, jsonApiSchema } from "./jsonApiSchema.module.js";
9
9
  export { default as matchers } from "./matchers.module.js";
10
10
  export { mockLogFactory, restoreLog, spyLog } from "./mockLog.module.js";
11
+ export { default as sqsTestRecords } from "./sqsTestRecords.function.js";
@@ -0,0 +1,53 @@
1
+ import { uuid } from "@jaypie/core";
2
+
3
+ //
4
+ //
5
+ // Constants
6
+ //
7
+
8
+ //
9
+ //
10
+ // Helper Functions
11
+ //
12
+
13
+ //
14
+ //
15
+ // Main
16
+ //
17
+
18
+ const sqsTestRecords = (...args) => {
19
+ const records = [];
20
+
21
+ // See if only a single array was passed in and spread it
22
+ if (args.length === 1 && Array.isArray(args[0])) {
23
+ // eslint-disable-next-line no-param-reassign
24
+ [args] = args;
25
+ }
26
+
27
+ for (let i = 0; i < args.length; i += 1) {
28
+ const item = args[i];
29
+ let body;
30
+ if (item && typeof item === "object") {
31
+ body = JSON.stringify(item);
32
+ } else {
33
+ // Cast item to string
34
+ body = String(item);
35
+ }
36
+ const record = {
37
+ messageId: uuid(),
38
+ body,
39
+ };
40
+ records.push(record);
41
+ }
42
+
43
+ return {
44
+ Records: records,
45
+ };
46
+ };
47
+
48
+ //
49
+ //
50
+ // Export
51
+ //
52
+
53
+ export default sqsTestRecords;