X-Git-Url: https://git.ladys.computer/Etiquette/blobdiff_plain/e3a2a78fdfb9d913f311ff1948038dfbcb758a05..6365487166d73a75e1c66b7c8d5683ac46741ed2:/model.test.js diff --git a/model.test.js b/model.test.js index a648d4f..15a2f54 100644 --- a/model.test.js +++ b/model.test.js @@ -186,8 +186,8 @@ describe("TagSystem", () => { ); }); - it("[[Call]] returns null if passed an invalid I·R·I", () => { - assertStrictEquals(Tag.fromIRI(`bad iri`), null); + it("[[Call]] throws if passed an invalid I·R·I", () => { + assertThrows(() => {Tag.fromIRI(`bad iri`)}); }); }); @@ -233,11 +233,11 @@ describe("TagSystem", () => { it("[[Call]] returns null if no tag with the given Tag U·R·I has been persisted", () => { assertStrictEquals( - Tag.fromIRI(`tag:${system.taggingEntity}:`), + Tag.fromTagURI(`tag:${system.taggingEntity}:`), null, ); assertStrictEquals( - Tag.fromIRI(`tag:${system.taggingEntity}:000-0000`), + Tag.fromTagURI(`tag:${system.taggingEntity}:000-0000`), null, ); }); @@ -306,6 +306,11 @@ describe("TagSystem", () => { ], ); }); + + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.addAltLabel(), tag); + }); }); describe("::addBroaderTag", () => { @@ -328,6 +333,11 @@ describe("TagSystem", () => { ); }); + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.addBroaderTag(), tag); + }); + it("[[Call]] throws when adding a non‐persisted tag", () => { const tag = new Tag(); assertThrows(() => { @@ -372,6 +382,11 @@ describe("TagSystem", () => { ], ); }); + + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.addHiddenLabel(), tag); + }); }); describe("::addInCanonTag", () => { @@ -394,6 +409,11 @@ describe("TagSystem", () => { ); }); + it("[[Call]] returns this", () => { + const tag = new Tag("EntityTag"); + assertStrictEquals(tag.addInCanonTag(), tag); + }); + it("[[Call]] throws when this is not a tag which can be placed in canon", () => { assertThrows(() => { new Tag().addInCanonTag(); @@ -447,6 +467,11 @@ describe("TagSystem", () => { ); }); + it("[[Call]] returns this", () => { + const tag = new Tag("ConceptualTag"); + assertStrictEquals(tag.addInvolvesTag(), tag); + }); + it("[[Call]] throws when this is not a conceptual tag", () => { assertThrows(() => { new Tag().addInvolvesTag(); @@ -547,6 +572,11 @@ describe("TagSystem", () => { ); assertEquals([...tag.altLabels()], ["four"]); }); + + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.deleteAltLabel(), tag); + }); }); describe("::deleteBroaderTag", () => { @@ -579,6 +609,11 @@ describe("TagSystem", () => { [broader2.identifier], ); }); + + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.deleteBroaderTag(), tag); + }); }); describe("::deleteHiddenLabel", () => { @@ -605,6 +640,11 @@ describe("TagSystem", () => { ); assertEquals([...tag.hiddenLabels()], ["four"]); }); + + it("[[Call]] returns this", () => { + const tag = new Tag(); + assertStrictEquals(tag.deleteHiddenLabel(), tag); + }); }); describe("::deleteInCanonTag", () => { @@ -633,6 +673,11 @@ describe("TagSystem", () => { [canon2.identifier], ); }); + + it("[[Call]] returns this", () => { + const tag = new Tag("EntityTag"); + assertStrictEquals(tag.deleteInCanonTag(), tag); + }); }); describe("::deleteInvolvesTag", () => { @@ -665,6 +710,11 @@ describe("TagSystem", () => { [involved2.identifier], ); }); + + it("[[Call]] returns this", () => { + const tag = new Tag("ConceptualTag"); + assertStrictEquals(tag.deleteInvolvesTag(), tag); + }); }); describe("::hasInCanonTags", () => { @@ -713,6 +763,8 @@ describe("TagSystem", () => { // `::iri` is tested by a `.fromIRI`. + // `::iriSpace` is tested by a `.fromIRI`. + // `::kind` is tested by the constructor. describe("::narrowerTags", () => { @@ -978,6 +1030,25 @@ describe("TagSystem", () => { }); }); + describe("::iriSpace", () => { + it("[[Get]] returns the I·R·I space", () => { + const system = new TagSystem("etaoin.example", "1972-12-31"); + assertStrictEquals( + system.iriSpace, + "https://etaoin.example/tag:etaoin.example,1972-12-31:", + ); + const system2 = new TagSystem( + "etaoin.example", + "1972-12-31", + "etaoin", + ); + assertStrictEquals( + system2.iriSpace, + "https://etaoin.example/tag:etaoin.example,1972-12-31:", + ); + }); + }); + describe("::tagURI", () => { it("[[Get]] returns the Tag U·R·I", () => { const system = new TagSystem("etaoin.example", "1972-12-31");