@@ -3,8 +3,46 @@ import { readFile } from "../../../test/fs.utils.js";
33import path from "path" ;
44import { fromJson } from "./index.js" ;
55import { strict as assert } from "node:assert" ;
6+ import {
7+ hasDuplicateNodeLabelIds ,
8+ hasDuplicateNodeObjectTypeIds ,
9+ } from "./extensions.js" ;
10+ import { RootSchemaJsonStruct } from "./types.js" ;
611
712describe ( "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