-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
bbfd53a
commit de2f826
Showing
6 changed files
with
176 additions
and
4 deletions.
There are no files selected for viewing
144 changes: 144 additions & 0 deletions
144
arches_lingo/src/arches_lingo/fixtures/test_scheme.json
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,144 @@ | ||
{ | ||
"schemes": [ | ||
{ | ||
"id": "c9c8548f-6ecc-40d5-ad67-42e9a7e7242e", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Test Scheme", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"top_concepts": [ | ||
{ | ||
"id": "943a70f1-236e-4c28-b5ab-69a4b83a63e9", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 1", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "8f7a7ca8-8548-464b-8fb7-01b3cec6487d", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 3", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "15bb81ff-194e-4fea-b495-b222f431caee", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 4", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "edf8dd01-a3fe-445e-a330-dc3bd04c7302", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 5", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "53ee9df5-3fa8-4686-a25b-ea8034cc4a5c", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 2", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "8f7a7ca8-8548-464b-8fb7-01b3cec6487d", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 3", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "15bb81ff-194e-4fea-b495-b222f431caee", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 4", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "edf8dd01-a3fe-445e-a330-dc3bd04c7302", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 5", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "15bb81ff-194e-4fea-b495-b222f431caee", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 4", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [ | ||
{ | ||
"id": "edf8dd01-a3fe-445e-a330-dc3bd04c7302", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 5", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [] | ||
} | ||
] | ||
}, | ||
{ | ||
"id": "edf8dd01-a3fe-445e-a330-dc3bd04c7302", | ||
"labels": [ | ||
{ | ||
"language": "en", | ||
"value": "Concept 5", | ||
"valuetype": "prefLabel" | ||
} | ||
], | ||
"narrower": [] | ||
} | ||
] | ||
} | ||
] | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { ENGLISH } from "@/arches_lingo/constants.ts"; | ||
import { treeFromSchemes } from "@/arches_lingo/utils.ts"; | ||
import schemesFixture from "./fixtures/test_scheme.json"; | ||
|
||
import type { IconLabels, Scheme } from "@/arches_lingo/types"; | ||
|
||
const iconLabels: IconLabels = { | ||
concept: "Concept", | ||
scheme: "Scheme", | ||
}; | ||
|
||
describe("Build scheme hierarchy", () => { | ||
it("Should shape schemes into TreeNodes", () => { | ||
const nodes = treeFromSchemes( | ||
schemesFixture["schemes"] as Scheme[], | ||
ENGLISH, | ||
iconLabels, | ||
null, | ||
); | ||
const schemeNode = nodes[0]; | ||
expect(schemeNode.label).toEqual("Test Scheme"); | ||
expect(schemeNode.iconLabel).toEqual("Scheme"); | ||
expect(schemeNode.data.top_concepts.length).toEqual(1); | ||
|
||
const topConcept = schemeNode.data.top_concepts[0]; | ||
expect(topConcept.labels[0].value).toEqual("Concept 1"); | ||
expect(topConcept.narrower.length).toEqual(4); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters