@jaypie/testkit 0.1.0 → 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/README.md +1 -1
- package/package.json +6 -1
- package/src/__tests__/index.spec.js +13 -1
- package/src/__tests__/jsonApiSchema.module.spec.js +17 -0
- package/src/__tests__/matchers.module.spec.js +39 -0
- package/src/index.js +2 -0
- package/src/jsonApiSchema.module.js +38 -0
- package/src/matchers.module.js +11 -0
package/README.md
CHANGED
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,8 +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",
|
|
17
|
+
"test:spec:matchers.module": "vitest run ./src/__tests__/matchers.module.spec.js",
|
|
16
18
|
"test:spec:mockLog.module": "vitest run ./src/__tests__/mockLog.module.spec.js"
|
|
17
19
|
},
|
|
20
|
+
"dependencies": {
|
|
21
|
+
"jest-json-schema": "^6.1.0"
|
|
22
|
+
},
|
|
18
23
|
"devDependencies": {
|
|
19
24
|
"eslint": "^8.57.0",
|
|
20
25
|
"eslint-config-prettier": "^9.1.0",
|
|
@@ -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
|
//
|
|
@@ -14,4 +21,9 @@ describe("Index", () => {
|
|
|
14
21
|
expect(restoreLog).toBeFunction();
|
|
15
22
|
expect(spyLog).toBeFunction();
|
|
16
23
|
});
|
|
24
|
+
it("Exports matchers", () => {
|
|
25
|
+
expect(jsonApiErrorSchema).toBeObject();
|
|
26
|
+
expect(jsonApiSchema).toBeObject();
|
|
27
|
+
expect(matchers).toBeObject();
|
|
28
|
+
});
|
|
17
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
|
+
});
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// eslint-disable-next-line no-unused-vars
|
|
2
|
+
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
|
|
3
|
+
|
|
4
|
+
// Subject
|
|
5
|
+
import matchers from "../matchers.module.js";
|
|
6
|
+
|
|
7
|
+
//
|
|
8
|
+
//
|
|
9
|
+
// Mock constants
|
|
10
|
+
//
|
|
11
|
+
|
|
12
|
+
//
|
|
13
|
+
//
|
|
14
|
+
// Mock modules
|
|
15
|
+
//
|
|
16
|
+
|
|
17
|
+
//
|
|
18
|
+
//
|
|
19
|
+
// Mock environment
|
|
20
|
+
//
|
|
21
|
+
|
|
22
|
+
const DEFAULT_ENV = process.env;
|
|
23
|
+
beforeEach(() => {
|
|
24
|
+
process.env = { ...process.env };
|
|
25
|
+
});
|
|
26
|
+
afterEach(() => {
|
|
27
|
+
process.env = DEFAULT_ENV;
|
|
28
|
+
});
|
|
29
|
+
|
|
30
|
+
//
|
|
31
|
+
//
|
|
32
|
+
// Run tests
|
|
33
|
+
//
|
|
34
|
+
|
|
35
|
+
describe("Matchers Module", () => {
|
|
36
|
+
it("Is an object", () => {
|
|
37
|
+
expect(matchers).toBeObject();
|
|
38
|
+
});
|
|
39
|
+
});
|
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
|
+
};
|