|
1 | 1 | import VocabularyUtils from "../VocabularyUtils";
|
2 | 2 | import JsonLdUtils from "../JsonLdUtils";
|
3 | 3 | import { CONTEXT as VOCABULARY_CONTEXT } from "../../model/Vocabulary";
|
| 4 | +import { CONTEXT as TERM_CONTEXT, TermData } from "../../model/Term"; |
4 | 5 |
|
5 | 6 | describe("JsonLdUtils", () => {
|
6 | 7 | describe("resolveReferences", () => {
|
@@ -73,6 +74,76 @@ describe("JsonLdUtils", () => {
|
73 | 74 | expect(result.document.vocabulary).toEqual(result);
|
74 | 75 | });
|
75 | 76 | });
|
| 77 | + |
| 78 | + it("does not add empty arrays for plural language containers", () => { |
| 79 | + const input = { |
| 80 | + "@context": { |
| 81 | + types: "@type", |
| 82 | + sources: "http://purl.org/dc/terms/source", |
| 83 | + notations: "http://www.w3.org/2004/02/skos/core#notation", |
| 84 | + label: { |
| 85 | + "@id": "http://www.w3.org/2004/02/skos/core#prefLabel", |
| 86 | + "@container": "@language", |
| 87 | + }, |
| 88 | + uri: "@id", |
| 89 | + subTerms: "http://www.w3.org/2004/02/skos/core#narrower", |
| 90 | + glossary: "http://www.w3.org/2004/02/skos/core#inScheme", |
| 91 | + vocabulary: |
| 92 | + "http://onto.fel.cvut.cz/ontologies/slovník/agendový/popis-dat/pojem/je-pojmem-ze-slovníku", |
| 93 | + hiddenLabels: "http://www.w3.org/2004/02/skos/core#hiddenLabel", |
| 94 | + examples: "http://www.w3.org/2004/02/skos/core#example", |
| 95 | + related: "http://www.w3.org/2004/02/skos/core#related", |
| 96 | + relatedMatch: "http://www.w3.org/2004/02/skos/core#relatedMatch", |
| 97 | + definition: { |
| 98 | + "@id": "http://www.w3.org/2004/02/skos/core#definition", |
| 99 | + "@container": "@language", |
| 100 | + }, |
| 101 | + state: |
| 102 | + "http://onto.fel.cvut.cz/ontologies/slovník/agendový/popis-dat/pojem/má-stav-pojmu", |
| 103 | + parentTerms: "http://www.w3.org/2004/02/skos/core#broader", |
| 104 | + altLabels: { |
| 105 | + "@id": "http://www.w3.org/2004/02/skos/core#altLabel", |
| 106 | + "@container": "@language", |
| 107 | + }, |
| 108 | + exactMatchTerms: "http://www.w3.org/2004/02/skos/core#exactMatch", |
| 109 | + }, |
| 110 | + uri: "http://onto.fel.cvut.cz/ontologies/slovnik/ml-test/pojem/lokalita", |
| 111 | + types: [ |
| 112 | + "http://onto.fel.cvut.cz/ontologies/ufo/object", |
| 113 | + "http://www.w3.org/2004/02/skos/core#Concept", |
| 114 | + ], |
| 115 | + label: { |
| 116 | + cs: "Lokalita", |
| 117 | + en: "Locality", |
| 118 | + }, |
| 119 | + subTerms: [], |
| 120 | + notations: [], |
| 121 | + definition: { |
| 122 | + cs: "Plocha nebo soubor ploch, popřípadě část plochy, vymezená na základě převažujícího charakteru. Upraveno. Ještě přidána explicitně zmíněná testovací plocha, aby se nám přidala do definičně souvisejících pojmů.\n\nDefinice znovu upravena, abychom spustili textovou analýzu. A znovu.", |
| 123 | + en: "English definition of the term Locality is just a placeholder proving that multilingual definition works.", |
| 124 | + }, |
| 125 | + sources: [], |
| 126 | + altLabels: [], |
| 127 | + hiddenLabels: [], |
| 128 | + examples: [], |
| 129 | + vocabulary: { |
| 130 | + uri: "http://onto.fel.cvut.cz/ontologies/slovnik/ml-test", |
| 131 | + }, |
| 132 | + glossary: { |
| 133 | + uri: "http://onto.fel.cvut.cz/ontologies/slovnik/ml-test/glosář", |
| 134 | + }, |
| 135 | + state: { |
| 136 | + uri: "http://onto.fel.cvut.cz/ontologies/application/termit/pojem/publikovaný-pojem", |
| 137 | + }, |
| 138 | + }; |
| 139 | + return JsonLdUtils.compactAndResolveReferences(input, TERM_CONTEXT).then( |
| 140 | + (result: TermData) => { |
| 141 | + expect(result[VocabularyUtils.SKOS_ALT_LABEL]).not.toBeDefined(); |
| 142 | + expect(result[VocabularyUtils.SKOS_HIDDEN_LABEL]).not.toBeDefined(); |
| 143 | + expect(result[VocabularyUtils.SKOS_EXAMPLE]).not.toBeDefined(); |
| 144 | + } |
| 145 | + ); |
| 146 | + }); |
76 | 147 | });
|
77 | 148 |
|
78 | 149 | describe("compactAndResolveReferencesAsArray", () => {
|
|
0 commit comments