Skip to content

Commit 0317cf7

Browse files
committed
test: unit test on unit functions
1 parent 86c4c48 commit 0317cf7

File tree

1 file changed

+38
-0
lines changed

1 file changed

+38
-0
lines changed

packages/graph-schema-utils/src/formatters/json/extensions.test.ts

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,46 @@ import { readFile } from "../../../test/fs.utils.js";
33
import path from "path";
44
import { fromJson } from "./index.js";
55
import { strict as assert } from "node:assert";
6+
import {
7+
hasDuplicateNodeLabelIds,
8+
hasDuplicateNodeObjectTypeIds,
9+
} from "./extensions.js";
10+
import { RootSchemaJsonStruct } from "./types.js";
611

712
describe("JSON formatter", () => {
13+
describe("hasDuplicateNodeLabelIds", () => {
14+
test("Identifies duplicated node labels", () => {
15+
const schema = readFile(
16+
path.resolve(__dirname, "./test-schemas/duplicated-nodeLabel-ids.json")
17+
);
18+
const schemaJson = JSON.parse(schema) as RootSchemaJsonStruct;
19+
20+
assert.strictEqual(
21+
hasDuplicateNodeLabelIds(
22+
schemaJson.graphSchemaRepresentation.graphSchema
23+
),
24+
true
25+
);
26+
});
27+
});
28+
describe("hasDuplicateNodeObjectTypeIds", () => {
29+
test("Identifies duplicated node object types", () => {
30+
const schema = readFile(
31+
path.resolve(
32+
__dirname,
33+
"./test-schemas/duplicated-nodeObjectType-ids.json"
34+
)
35+
);
36+
const schemaJson = JSON.parse(schema) as RootSchemaJsonStruct;
37+
38+
assert.strictEqual(
39+
hasDuplicateNodeObjectTypeIds(
40+
schemaJson.graphSchemaRepresentation.graphSchema
41+
),
42+
true
43+
);
44+
});
45+
});
846
describe("fromJson", () => {
947
const schemaWithDuplicatedNodeLabels = readFile(
1048
path.resolve(__dirname, "./test-schemas/duplicated-nodeLabel-ids.json")

0 commit comments

Comments
 (0)