]>
Lady’s Gitweb - Etiquette/blob - model.test.js
3e9982a7a4fb513495204b5d80608e4d04f2c6a9
1 // 📧🏷️ Étiquette ∷ model.test.js
2 // ====================================================================
4 // Copyright © 2023 Lady [@ Lady’s Computer].
6 // This Source Code Form is subject to the terms of the Mozilla Public
7 // License, v. 2.0. If a copy of the MPL was not distributed with this
8 // file, You can obtain one at <https://mozilla.org/MPL/2.0/>.
21 } from "./dev-deps.js";
22 import { TagSystem
} from "./model.js";
24 describe("TagSystem", () => {
25 it("[[Call]] throws", () => {
31 it("[[Construct]] creates a new TagSystem", () => {
33 Object
.getPrototypeOf(new TagSystem("example", "1972-12-31")),
38 it("[[Construct]] uses the identifier if provided", () => {
40 new TagSystem("example", "1972-12-31", "etaoin").identifier
,
45 it("[[Construct]] uses an empty identifier if none is provided", () => {
47 new TagSystem("example", "1972-12-31").identifier
,
52 it("[[Construct]] throws if provided an invalid domain", () => {
54 new TagSystem("example@example", "1972-12-31");
57 new TagSystem("0.0.0.0", "1972-12-31");
61 it("[[Construct]] throws if provided an invalid date", () => {
63 new TagSystem("example", "1969");
66 new TagSystem("example", "1972-12-31T00:00:00Z");
70 describe("::Tag", () => {
75 system
= new TagSystem("example", "1972-12-31");
79 it("[[Get]] returns the same value every time", () => {
80 assertStrictEquals(Tag
, system
.Tag
);
83 it("[[Call]] throws", () => {
89 it("[[Construct]] returns a new Tag", () => {
91 Object
.getPrototypeOf(new Tag()),
96 it('[[Construct]] defaults the kind to "Tag"', () => {
97 assertStrictEquals(new Tag().kind
, "Tag");
100 it("[[Construct]] correctly sets the tag kind", () => {
102 new Tag("RelationshipTag").kind
,
107 it("[[Construct]] defaults the preferred label to the empty string", () => {
108 assertEquals({ ...new Tag().prefLabel
}, { "@value": "" });
111 it("[[Construct]] correctly sets the preferred label to a simple string", () => {
113 { ...new Tag("RelationshipTag", "Shadow, Me").prefLabel
},
114 { "@value": "Shadow, Me" },
118 it("[[Construct]] initializes tag identifiers to null", () => {
120 new Tag().identifier
,
125 it("[[Construct]] correctly sets the preferred label to a language‐tagged string", () => {
128 ...new Tag("RelationshipTag", {
129 "@value": "Shadow, Me",
133 { "@value": "Shadow, Me", "@language": "en" },
137 it("[[Construct]] throws if the tag kind is not recognized", () => {
143 describe(".all", () => {
144 it("[[Call]] yields all the persisted tags", () => {
145 const tags
= new Set(function* () {
148 // Generate 5 tags and remember their identifiers.
149 const tag
= new Tag();
151 yield tag
.identifier
;
154 for (const tag
of Tag
.all()) {
156 Object
.getPrototypeOf(tag
),
161 new Set(Array
.from(Tag
.all(), (tag
) => tag
.identifier
)),
167 describe(".fromIRI", () => {
168 it("[[Call]] returns the persisted tag with the given I·R·I", () => {
169 const tag
= new Tag();
171 const { identifier
, iri
} = tag
;
172 const retrieved
= Tag
.fromIRI(iri
);
174 Object
.getPrototypeOf(retrieved
),
177 assertStrictEquals(retrieved
.identifier
, identifier
);
180 it("[[Call]] returns null if no tag with the given I·R·I has been persisted", () => {
183 `https://${system.authorityName}/tag:${system.taggingEntity}:000-0000`,
189 it("[[Call]] throws if passed an invalid I·R·I", () => {
191 Tag
.fromIRI(`bad iri`);
196 describe(".fromIdentifier", () => {
197 it("[[Call]] returns the persisted tag with the given identifier", () => {
198 const tag
= new Tag();
200 const { identifier
} = tag
;
201 const retrieved
= Tag
.fromIdentifier(identifier
);
203 Object
.getPrototypeOf(retrieved
),
206 assertStrictEquals(retrieved
.identifier
, identifier
);
209 it("[[Call]] returns null if no tag with the given identifier has been persisted", () => {
210 assertStrictEquals(Tag
.fromIdentifier("000-0000"), null);
213 it("[[Call]] throws if passed an invalid identifier", () => {
215 Tag
.fromIdentifier(""); // wrong format
218 Tag
.fromIdentifier("100-0000"); // bad checksum
223 describe(".fromTagURI", () => {
224 it("[[Call]] returns the persisted tag with the given Tag U·R·I", () => {
225 const tag
= new Tag();
227 const { identifier
, tagURI
} = tag
;
228 const retrieved
= Tag
.fromTagURI(tagURI
);
230 Object
.getPrototypeOf(retrieved
),
233 assertStrictEquals(retrieved
.identifier
, identifier
);
236 it("[[Call]] returns null if no tag with the given Tag U·R·I has been persisted", () => {
238 Tag
.fromTagURI(`tag:${system.taggingEntity}:`),
242 Tag
.fromTagURI(`tag:${system.taggingEntity}:000-0000`),
247 it("[[Call]] throws if passed an invalid Tag U·R·I", () => {
249 Tag
.fromTagURI(""); // wrong format
253 "tag:unexample,1970-01-01:Z", // incorrect tagging entity
259 describe(".getSystem", () => {
260 it("[[Has]] is not present", () => {
261 assertFalse("getSystem" in Tag
);
265 describe(".identifiers", () => {
266 it("[[Call]] yields all the persisted identifiers", () => {
267 const tags
= new Set(function* () {
270 // Generate 5 tags and remember their identifiers.
271 const tag
= new Tag();
273 yield tag
.identifier
;
277 new Set(Tag
.identifiers()),
283 // `.[Storage.toInstance]` is tested by `.fromIdentifier`.
285 describe("::addAltLabel", () => {
286 it("[[Call]] does nothing if called with no arguments", () => {
287 const tag
= new Tag();
289 assertEquals([...tag
.altLabels()], []);
292 it("[[Call]] adds the provided alternative labels", () => {
293 const tag
= new Tag();
297 { "@value": "three", "@language": "en" },
300 Array
.from(tag
.altLabels(), ($) => ({ ...$ })),
304 { "@value": "three", "@language": "en" },
309 it("[[Call]] returns this", () => {
310 const tag
= new Tag();
311 assertStrictEquals(tag
.addAltLabel(), tag
);
315 describe("::addBroaderTag", () => {
316 it("[[Call]] does nothing if called with no arguments", () => {
317 const tag
= new Tag();
319 assertEquals([...tag
.broaderTags()], []);
322 it("[[Call]] adds the provided broader tags", () => {
323 const broader
= new Tag();
325 const broader2
= new Tag();
327 const tag
= new Tag();
328 tag
.addBroaderTag(broader
, broader2
);
330 Array
.from(tag
.broaderTags(), ($) => $.identifier
),
331 [broader
.identifier
, broader2
.identifier
],
335 it("[[Call]] returns this", () => {
336 const tag
= new Tag();
337 assertStrictEquals(tag
.addBroaderTag(), tag
);
340 it("[[Call]] throws when adding a non‐persisted tag", () => {
341 const tag
= new Tag();
343 tag
.addBroaderTag(new Tag());
347 it("[[Call]] throws when adding an unrecognized identifier", () => {
348 const tag
= new Tag();
350 tag
.addBroaderTag("000-0000"); // not persisted
353 tag
.addBroaderTag(""); // bad format
358 describe("::addHiddenLabel", () => {
359 it("[[Call]] does nothing if called with no arguments", () => {
360 const tag
= new Tag();
361 tag
.addHiddenLabel();
362 assertEquals([...tag
.hiddenLabels()], []);
365 it("[[Call]] adds the provided hidden labels", () => {
366 const tag
= new Tag();
370 { "@value": "three", "@language": "en" },
373 Array
.from(tag
.hiddenLabels(), ($) => ({ ...$ })),
377 { "@value": "three", "@language": "en" },
382 it("[[Call]] returns this", () => {
383 const tag
= new Tag();
384 assertStrictEquals(tag
.addHiddenLabel(), tag
);
388 describe("::addInCanonTag", () => {
389 it("[[Call]] does nothing if called with no arguments", () => {
390 const tag
= new Tag("EntityTag");
392 assertEquals([...tag
.inCanonTags()], []);
395 it("[[Call]] adds the provided canon tags", () => {
396 const canon
= new Tag("CanonTag");
398 const canon2
= new Tag("CanonTag");
400 const tag
= new Tag("EntityTag");
401 tag
.addInCanonTag(canon
, canon2
);
403 Array
.from(tag
.inCanonTags(), ($) => $.identifier
),
404 [canon
.identifier
, canon2
.identifier
],
408 it("[[Call]] returns this", () => {
409 const tag
= new Tag("EntityTag");
410 assertStrictEquals(tag
.addInCanonTag(), tag
);
413 it("[[Call]] throws when this is not a tag which can be placed in canon", () => {
415 new Tag().addInCanonTag();
419 it("[[Call]] throws when provided with a non‐canon tag", () => {
420 const notCanon
= new Tag();
422 const tag
= new Tag("EntityTag");
424 tag
.addInCanonTag(notCanon
);
428 it("[[Call]] throws when adding a non‐persisted tag", () => {
429 const tag
= new Tag("EntityTag");
431 tag
.addInCanonTag(new Tag("CanonTag"));
435 it("[[Call]] throws when adding an unrecognized identifier", () => {
436 const tag
= new Tag("EntityTag");
438 tag
.addInCanonTag("000-0000"); // not persisted
441 tag
.addInCanonTag(""); // bad format
446 describe("::addInvolvesTag", () => {
447 it("[[Call]] does nothing if called with no arguments", () => {
448 const tag
= new Tag("ConceptualTag");
449 tag
.addInvolvesTag();
450 assertEquals([...tag
.involvesTags()], []);
453 it("[[Call]] adds the provided tags", () => {
454 const involved
= new Tag();
456 const involved2
= new Tag();
458 const tag
= new Tag("ConceptualTag");
459 tag
.addInvolvesTag(involved
, involved2
);
461 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
462 [involved
.identifier
, involved2
.identifier
],
466 it("[[Call]] returns this", () => {
467 const tag
= new Tag("ConceptualTag");
468 assertStrictEquals(tag
.addInvolvesTag(), tag
);
471 it("[[Call]] throws when this is not a conceptual tag", () => {
473 new Tag().addInvolvesTag();
477 it("[[Call]] throws when this is a relationship tag and provided with a non‐involvable tag", () => {
478 const notInvolved
= new Tag();
479 notInvolved
.persist();
480 const tag
= new Tag("RelationshipTag");
482 tag
.addInvolvesTag(notInvolved
);
486 it("[[Call]] throws when adding a non‐persisted tag", () => {
487 const tag
= new Tag("ConceptualTag");
489 tag
.addInvolvesTag(new Tag());
493 it("[[Call]] throws when adding an unrecognized identifier", () => {
494 const tag
= new Tag("ConceptualTag");
496 tag
.addInvolvesTag("000-0000"); // not persisted
499 tag
.addInvolvesTag(""); // bad format
504 // `::altLabels` is tested by `::addAltLabel`.
506 describe("::authorityName", () => {
507 it("[[Get]] returns the authority name of the tag system", () => {
509 new Tag().authorityName
,
510 system
.authorityName
,
515 // `::broaderTags` is tested by `::addBroaderTag`.
517 describe("::broaderTransitiveTags", () => {
518 it("[[Call]] returns broader tags transitively", () => {
519 const superBroad
= new Tag();
520 superBroad
.persist();
521 const broad
= new Tag();
522 broad
.addBroaderTag(superBroad
);
524 const tag
= new Tag();
525 tag
.addBroaderTag(broad
);
527 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
528 [broad
.identifier
, superBroad
.identifier
],
532 it("[[Call]] cannot recurse infinitely", () => {
533 const tag
= new Tag();
535 const broad
= new Tag();
536 broad
.addBroaderTag(tag
);
538 tag
.addBroaderTag(broad
);
541 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
542 [broad
.identifier
, tag
.identifier
],
547 describe("::deleteAltLabel", () => {
548 it("[[Call]] does nothing if called with no arguments", () => {
549 const tag
= new Tag();
550 tag
.addAltLabel("etaoin");
551 tag
.deleteAltLabel();
553 Array
.from(tag
.altLabels(), ($) => ({ ...$ })),
554 [{ "@value": "etaoin" }],
558 it("[[Call]] deletes only the provided hidden labels", () => {
559 const tag
= new Tag();
563 { "@value": "three", "@language": "en" },
569 { "@value": "three", "@language": "en" },
570 { "@value": "four", "@language": "en" },
573 Array
.from(tag
.altLabels(), ($) => ({ ...$ })),
574 [{ "@value": "four" }],
578 it("[[Call]] returns this", () => {
579 const tag
= new Tag();
580 assertStrictEquals(tag
.deleteAltLabel(), tag
);
584 describe("::deleteBroaderTag", () => {
585 it("[[Call]] does nothing if called with no arguments", () => {
586 const broader
= new Tag();
588 const tag
= new Tag();
589 tag
.addBroaderTag(broader
);
590 tag
.deleteBroaderTag();
592 Array
.from(tag
.broaderTags(), ($) => $.identifier
),
593 [broader
.identifier
],
597 it("[[Call]] deletes only the provided broader tags", () => {
598 const superBroader
= new Tag();
599 superBroader
.persist();
600 const broader
= new Tag();
601 broader
.addBroaderTag(superBroader
);
603 const broader2
= new Tag();
604 broader2
.addBroaderTag(superBroader
);
606 const tag
= new Tag();
607 tag
.addBroaderTag(broader
, broader2
);
608 tag
.deleteBroaderTag(broader
, superBroader
, "000-0000", "");
610 Array
.from(tag
.broaderTags(), ($) => $.identifier
),
611 [broader2
.identifier
],
615 it("[[Call]] returns this", () => {
616 const tag
= new Tag();
617 assertStrictEquals(tag
.deleteBroaderTag(), tag
);
621 describe("::deleteHiddenLabel", () => {
622 it("[[Call]] does nothing if called with no arguments", () => {
623 const tag
= new Tag();
624 tag
.addHiddenLabel("etaoin");
625 tag
.deleteHiddenLabel();
627 Array
.from(tag
.hiddenLabels(), ($) => ({ ...$ })),
628 [{ "@value": "etaoin" }],
632 it("[[Call]] deletes only the provided alternative labels", () => {
633 const tag
= new Tag();
637 { "@value": "three", "@language": "en" },
640 tag
.deleteHiddenLabel(
643 { "@value": "three", "@language": "en" },
644 { "@value": "four", "@language": "en" },
647 Array
.from(tag
.hiddenLabels(), ($) => ({ ...$ })),
648 [{ "@value": "four" }],
652 it("[[Call]] returns this", () => {
653 const tag
= new Tag();
654 assertStrictEquals(tag
.deleteHiddenLabel(), tag
);
658 describe("::deleteInCanonTag", () => {
659 it("[[Call]] does nothing if called with no arguments", () => {
660 const canon
= new Tag("CanonTag");
662 const tag
= new Tag("EntityTag");
663 tag
.addInCanonTag(canon
);
664 tag
.deleteInCanonTag();
666 Array
.from(tag
.inCanonTags(), ($) => $.identifier
),
671 it("[[Call]] deletes only the provided canon tags", () => {
672 const canon
= new Tag("CanonTag");
674 const canon2
= new Tag("CanonTag");
676 const tag
= new Tag("EntityTag");
677 tag
.addInCanonTag(canon
, canon2
);
678 tag
.deleteInCanonTag(canon
, "000-0000", "");
680 Array
.from(tag
.inCanonTags(), ($) => $.identifier
),
685 it("[[Call]] returns this", () => {
686 const tag
= new Tag("EntityTag");
687 assertStrictEquals(tag
.deleteInCanonTag(), tag
);
691 describe("::deleteInvolvesTag", () => {
692 it("[[Call]] does nothing if called with no arguments", () => {
693 const involved
= new Tag();
695 const tag
= new Tag("ConceptualTag");
696 tag
.addInvolvesTag(involved
);
697 tag
.deleteInvolvesTag();
699 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
700 [involved
.identifier
],
704 it("[[Call]] deletes only the provided involved tags", () => {
705 const character
= new Tag("CharacterTag");
707 const involved
= new Tag("RelationshipTag");
708 involved
.addInvolvesTag(character
);
710 const involved2
= new Tag("RelationshipTag");
711 involved2
.addInvolvesTag(character
);
713 const tag
= new Tag("RelationshipTag");
714 tag
.addInvolvesTag(involved
, involved2
);
715 tag
.deleteInvolvesTag(involved
, character
, "000-0000", "");
717 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
718 [involved2
.identifier
],
722 it("[[Call]] returns this", () => {
723 const tag
= new Tag("ConceptualTag");
724 assertStrictEquals(tag
.deleteInvolvesTag(), tag
);
728 describe("::hasInCanonTags", () => {
729 it("[[Call]] yields the persisted tags which have this tag in canon", () => {
730 const canon
= new Tag("CanonTag");
732 const entity
= new Tag("EntityTag");
733 entity
.addInCanonTag(canon
);
735 const entity2
= new Tag("EntityTag");
736 entity2
.addInCanonTag(canon
);
738 const tag
= Tag
.fromIdentifier(canon
.identifier
); // reload
740 Array
.from(tag
.hasInCanonTags(), ($) => $.identifier
),
741 [entity
.identifier
, entity2
.identifier
],
746 // `::hiddenLabels` is tested by `::addHiddenLabel`.
748 // `::identifier` is tested by a `.fromIdentifier`.
750 // `::inCanonTags` is tested by `::addInCanonTag`.
752 describe("::involvedInTags", () => {
753 it("[[Call]] yields the persisted tags which involve this tag", () => {
754 const involved
= new Tag();
756 const conceptual
= new Tag("ConceptualTag");
757 conceptual
.addInvolvesTag(involved
);
758 conceptual
.persist();
759 const conceptual2
= new Tag("ConceptualTag");
760 conceptual2
.addInvolvesTag(involved
);
761 conceptual2
.persist();
762 const tag
= Tag
.fromIdentifier(involved
.identifier
); // reload
764 Array
.from(tag
.involvedInTags(), ($) => $.identifier
),
765 [conceptual
.identifier
, conceptual2
.identifier
],
770 // `::involvesTags` is tested by `::addInvolvesTag`.
772 // `::iri` is tested by a `.fromIRI`.
774 // `::iriSpace` is tested by a `.fromIRI`.
776 // `::kind` is tested by the constructor.
778 describe("::narrowerTags", () => {
779 it("[[Call]] yields the persisted tags which are narrower than this tag", () => {
780 const broader
= new Tag();
782 const narrower
= new Tag();
783 narrower
.addBroaderTag(broader
);
785 const narrower2
= new Tag();
786 narrower2
.addBroaderTag(broader
);
788 const tag
= Tag
.fromIdentifier(broader
.identifier
); // reload
790 Array
.from(tag
.narrowerTags(), ($) => $.identifier
),
791 [narrower
.identifier
, narrower2
.identifier
],
796 describe("::narrowerTransitiveTags", () => {
797 it("[[Call]] returns narrower tags transitively", () => {
798 const broad
= new Tag();
800 const narrow
= new Tag();
801 narrow
.addBroaderTag(broad
);
803 const superNarrow
= new Tag();
804 superNarrow
.addBroaderTag(narrow
);
805 superNarrow
.persist();
806 const tag
= Tag
.fromIdentifier(broad
.identifier
); // reload
809 tag
.narrowerTransitiveTags(),
812 [narrow
.identifier
, superNarrow
.identifier
],
816 it("[[Call]] cannot recurse infinitely", () => {
817 const tag
= new Tag();
819 const broad
= new Tag();
820 broad
.addBroaderTag(tag
);
822 tag
.addBroaderTag(broad
);
825 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
826 [broad
.identifier
, tag
.identifier
],
831 describe("::persist", () => {
832 it("[[Call]] returns an object with expected properties if there were changes", () => {
833 const tag
= new Tag();
834 const activity
= tag
.persist();
839 "https://ns.1024.gdn/Tagging/discovery.context.jsonld",
844 assertArrayIncludes(activity
["@type"], ["TagActivity"]);
845 assert("endTime" in activity
);
848 it("[[Call]] returns a Create activity with a type predicate for new objects", () => {
849 const activity
= new Tag().persist();
850 assertEquals(activity
["@type"], ["TagActivity", "Create"]);
851 assertArrayIncludes(activity
.states
, [{
857 it("[[Call]] returns an Update activity for old objects", () => {
858 const tag
= new Tag();
860 tag
.prefLabel
= "etaoin";
861 const activity
= tag
.persist();
862 assertEquals(activity
["@type"], ["TagActivity", "Update"]);
865 it("[[Call]] states and unstates changes", () => {
866 const broader1
= new Tag();
868 const broader2
= new Tag();
870 const tag
= new Tag();
871 tag
.addBroaderTag(broader1
);
873 tag
.prefLabel
= "etaoin";
874 tag
.deleteBroaderTag(broader1
);
875 tag
.addBroaderTag(broader2
);
876 const activity
= tag
.persist();
877 assertObjectMatch(activity
, {
879 { predicate
: "prefLabel", object
: { "@value": "" } },
880 { predicate
: "broader", object
: broader1
.iri
},
883 { predicate
: "prefLabel", object
: { "@value": "etaoin" } },
884 { predicate
: "broader", object
: broader2
.iri
},
889 it("[[Call]] doesn’t state if there are no additions", () => {
890 const tag
= new Tag();
891 tag
.addAltLabel("etaoin");
893 tag
.deleteAltLabel("etaoin");
894 const activity
= tag
.persist();
895 assertFalse("state" in activity
);
898 it("[[Call]] doesn’t unstate if there are no removals", () => {
899 const tag
= new Tag();
901 tag
.addAltLabel("etaoin");
902 const activity
= tag
.persist();
903 assertFalse("unstate" in activity
);
906 it("[[Call]] returns null if no meaningful changes were made", () => {
907 const tag
= new Tag();
909 const activity
= tag
.persist();
910 assertStrictEquals(activity
, null);
913 it("[[Call]] returns undefined for a silent persist", () => {
914 const broader
= new Tag();
916 const tag
= new Tag();
917 tag
.prefLabel
= "etaoin";
918 tag
.addBroaderTag(broader
);
919 assertStrictEquals(tag
.persist(true), undefined);
923 describe("::prefLabel", () => {
924 it("[[Set]] sets the preferred label", () => {
925 const tag
= new Tag();
926 tag
.prefLabel
= "one";
927 assertEquals({ ...tag
.prefLabel
}, { "@value": "one" });
928 tag
.prefLabel
= { "@value": "two" };
929 assertEquals({ ...tag
.prefLabel
}, { "@value": "two" });
930 tag
.prefLabel
= { "@value": "three", "@language": "en" };
932 { ...tag
.prefLabel
},
933 { "@value": "three", "@language": "en" },
938 // `::tagURI` is tested by a `.fromTagURI`.
940 describe("::taggingEntity", () => {
941 it("[[Get]] returns the tagging entity of the tag system", () => {
943 new Tag().taggingEntity
,
944 system
.taggingEntity
,
949 describe("::toString", () => {
950 it("[[Get]] returns the string value of the preferred label", () => {
951 const tag
= new Tag();
952 tag
.prefLabel
= { "@value": "etaoin", "@language": "zxx" };
953 assertStrictEquals(tag
.toString(), "etaoin");
957 // `::[Storage.toObject]` is tested by `::persist`.
960 describe("::authorityName", () => {
961 it("[[Get]] returns the authority name", () => {
962 const system
= new TagSystem("etaoin.example", "1972-12-31");
963 assertStrictEquals(system
.authorityName
, "etaoin.example");
967 describe("::authorityName", () => {
968 it("[[Get]] returns the date", () => {
969 const system
= new TagSystem("etaoin.example", "1972-12-31");
970 assertStrictEquals(system
.date
, "1972-12-31");
974 describe("::identifiers", () => {
975 it("[[Get]] yields the extant entities", () => {
976 const system
= new TagSystem("etaoin.example", "1972-12-31");
977 const tags
= new Set(function* () {
980 // Generate 5 tags and remember their identifiers.
981 const tag
= new system
.Tag();
983 yield tag
.identifier
;
987 new Set(Array
.from(system
.entities(), ($) => $.identifier
)),
993 describe("::identifier", () => {
994 it("[[Get]] returns the identifier", () => {
995 const system
= new TagSystem("etaoin.example", "1972-12-31");
996 assertStrictEquals(system
.identifier
, "");
997 const system2
= new TagSystem(
1002 assertStrictEquals(system2
.identifier
, "etaoin");
1006 describe("::identifiers", () => {
1007 it("[[Get]] yields the identifiers in use", () => {
1008 const system
= new TagSystem("etaoin.example", "1972-12-31");
1009 const tags
= new Set(function* () {
1012 // Generate 5 tags and remember their identifiers.
1013 const tag
= new system
.Tag();
1015 yield tag
.identifier
;
1018 assertEquals(new Set(system
.identifiers()), tags
);
1022 describe("::iri", () => {
1023 it("[[Get]] returns the I·R·I", () => {
1024 const system
= new TagSystem("etaoin.example", "1972-12-31");
1027 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1029 const system2
= new TagSystem(
1036 "https://etaoin.example/tag:etaoin.example,1972-12-31:etaoin",
1041 describe("::iriSpace", () => {
1042 it("[[Get]] returns the I·R·I space", () => {
1043 const system
= new TagSystem("etaoin.example", "1972-12-31");
1046 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1048 const system2
= new TagSystem(
1055 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1060 describe("::tagURI", () => {
1061 it("[[Get]] returns the Tag U·R·I", () => {
1062 const system
= new TagSystem("etaoin.example", "1972-12-31");
1065 "tag:etaoin.example,1972-12-31:",
1067 const system2
= new TagSystem(
1074 "tag:etaoin.example,1972-12-31:etaoin",
1079 describe("::taggingEntity", () => {
1080 it("[[Get]] returns the tagging entity", () => {
1081 const system
= new TagSystem("etaoin.example", "1972-12-31");
1083 system
.taggingEntity
,
1084 "etaoin.example,1972-12-31",
This page took 0.247948 seconds and 3 git commands to generate.