@jaypie/testkit 0.1.1 → 0.1.2
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": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"author": "Finlayson Studio",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "src/index.js",
|
|
@@ -13,9 +13,13 @@
|
|
|
13
13
|
"new": "hygen jaypie vite",
|
|
14
14
|
"test": "vitest",
|
|
15
15
|
"test:spec:index": "vitest run ./src/__tests__/index.spec.js",
|
|
16
|
+
"test:spec:jsonApiSchema.module": "vitest run ./src/__tests__/jsonApiSchema.module.spec.js",
|
|
16
17
|
"test:spec:matchers.module": "vitest run ./src/__tests__/matchers.module.spec.js",
|
|
17
18
|
"test:spec:mockLog.module": "vitest run ./src/__tests__/mockLog.module.spec.js"
|
|
18
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"jest-json-schema": "^6.1.0"
|
|
22
|
+
},
|
|
19
23
|
"devDependencies": {
|
|
20
24
|
"eslint": "^8.57.0",
|
|
21
25
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -27,8 +31,5 @@
|
|
|
27
31
|
"prettier": "^3.2.5",
|
|
28
32
|
"sort-package-json": "^2.8.0",
|
|
29
33
|
"vitest": "^1.4.0"
|
|
30
|
-
},
|
|
31
|
-
"dependencies": {
|
|
32
|
-
"jest-json-schema": "^6.1.0"
|
|
33
34
|
}
|
|
34
35
|
}
|
|
@@ -1,7 +1,14 @@
|
|
|
1
1
|
import { describe, expect, it } from "vitest";
|
|
2
2
|
|
|
3
3
|
// Subject
|
|
4
|
-
import {
|
|
4
|
+
import {
|
|
5
|
+
jsonApiErrorSchema,
|
|
6
|
+
jsonApiSchema,
|
|
7
|
+
matchers,
|
|
8
|
+
mockLogFactory,
|
|
9
|
+
restoreLog,
|
|
10
|
+
spyLog,
|
|
11
|
+
} from "../index.js";
|
|
5
12
|
|
|
6
13
|
//
|
|
7
14
|
//
|
|
@@ -15,6 +22,8 @@ describe("Index", () => {
|
|
|
15
22
|
expect(spyLog).toBeFunction();
|
|
16
23
|
});
|
|
17
24
|
it("Exports matchers", () => {
|
|
25
|
+
expect(jsonApiErrorSchema).toBeObject();
|
|
26
|
+
expect(jsonApiSchema).toBeObject();
|
|
18
27
|
expect(matchers).toBeObject();
|
|
19
28
|
});
|
|
20
29
|
});
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
// eslint-disable-next-line no-unused-vars
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
// Subject
|
|
5
|
+
import { jsonApiErrorSchema, jsonApiSchema } from "../jsonApiSchema.module.js";
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
// Run tests
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
describe("Json Api Schema Module", () => {
|
|
13
|
+
it("Exports objects", () => {
|
|
14
|
+
expect(jsonApiSchema).toBeObject();
|
|
15
|
+
expect(jsonApiErrorSchema).toBeObject();
|
|
16
|
+
});
|
|
17
|
+
});
|
package/src/index.js
CHANGED
|
@@ -0,0 +1,38 @@
|
|
|
1
|
+
export const jsonApiErrorSchema = {
|
|
2
|
+
type: "object",
|
|
3
|
+
properties: {
|
|
4
|
+
errors: {
|
|
5
|
+
type: "array",
|
|
6
|
+
items: {
|
|
7
|
+
type: "object",
|
|
8
|
+
properties: {
|
|
9
|
+
status: { type: "number" },
|
|
10
|
+
title: { type: "string" },
|
|
11
|
+
detail: { type: "string" },
|
|
12
|
+
},
|
|
13
|
+
required: ["status", "title"],
|
|
14
|
+
},
|
|
15
|
+
},
|
|
16
|
+
},
|
|
17
|
+
required: ["errors"],
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export const jsonApiSchema = {
|
|
21
|
+
type: "object",
|
|
22
|
+
properties: {
|
|
23
|
+
data: {
|
|
24
|
+
type: "object",
|
|
25
|
+
properties: {
|
|
26
|
+
id: { type: "string" },
|
|
27
|
+
type: { type: "string" },
|
|
28
|
+
attributes: { type: "object" },
|
|
29
|
+
links: { type: "object" },
|
|
30
|
+
meta: { type: "object" },
|
|
31
|
+
relationships: { type: "object" },
|
|
32
|
+
},
|
|
33
|
+
required: ["id", "type"],
|
|
34
|
+
},
|
|
35
|
+
meta: { type: "object" },
|
|
36
|
+
},
|
|
37
|
+
required: ["data"],
|
|
38
|
+
};
|