]>
Lady’s Gitweb - Etiquette/blob - model.test.js
a92671c52d2a4a033ab575172ff6abe7e00f2117
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(".constructor", () => {
168 it("[[Get]] is `Function`", () => {
169 assertStrictEquals(Tag
.constructor, Function
);
173 describe(".fromIRI", () => {
174 it("[[Call]] returns the persisted tag with the given I·R·I", () => {
175 const tag
= new Tag();
177 const { identifier
, iri
} = tag
;
178 const retrieved
= Tag
.fromIRI(iri
);
180 Object
.getPrototypeOf(retrieved
),
183 assertStrictEquals(retrieved
.identifier
, identifier
);
186 it("[[Call]] returns null if no tag with the given I·R·I has been persisted", () => {
189 `https://${system.authorityName}/tag:${system.taggingEntity}:000-0000`,
195 it("[[Call]] throws if passed an invalid I·R·I", () => {
197 Tag
.fromIRI(`bad iri`);
202 describe(".fromIdentifier", () => {
203 it("[[Call]] returns the persisted tag with the given identifier", () => {
204 const tag
= new Tag();
206 const { identifier
} = tag
;
207 const retrieved
= Tag
.fromIdentifier(identifier
);
209 Object
.getPrototypeOf(retrieved
),
212 assertStrictEquals(retrieved
.identifier
, identifier
);
215 it("[[Call]] returns null if no tag with the given identifier has been persisted", () => {
216 assertStrictEquals(Tag
.fromIdentifier("000-0000"), null);
219 it("[[Call]] throws if passed an invalid identifier", () => {
221 Tag
.fromIdentifier(""); // wrong format
224 Tag
.fromIdentifier("100-0000"); // bad checksum
229 describe(".fromTagURI", () => {
230 it("[[Call]] returns the persisted tag with the given Tag U·R·I", () => {
231 const tag
= new Tag();
233 const { identifier
, tagURI
} = tag
;
234 const retrieved
= Tag
.fromTagURI(tagURI
);
236 Object
.getPrototypeOf(retrieved
),
239 assertStrictEquals(retrieved
.identifier
, identifier
);
242 it("[[Call]] returns null if no tag with the given Tag U·R·I has been persisted", () => {
244 Tag
.fromTagURI(`tag:${system.taggingEntity}:`),
248 Tag
.fromTagURI(`tag:${system.taggingEntity}:000-0000`),
253 it("[[Call]] throws if passed an invalid Tag U·R·I", () => {
255 Tag
.fromTagURI(""); // wrong format
259 "tag:unexample,1970-01-01:Z", // incorrect tagging entity
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", () => {
414 const canon
= new Tag("CanonTag");
417 new Tag().addInCanonTag(canon
);
421 it("[[Call]] throws when provided with a non‐canon tag", () => {
422 const notCanon
= new Tag();
424 const tag
= new Tag("EntityTag");
426 tag
.addInCanonTag(notCanon
);
430 it("[[Call]] throws when adding a non‐persisted tag", () => {
431 const tag
= new Tag("EntityTag");
433 tag
.addInCanonTag(new Tag("CanonTag"));
437 it("[[Call]] throws when adding an unrecognized identifier", () => {
438 const tag
= new Tag("EntityTag");
440 tag
.addInCanonTag("000-0000"); // not persisted
443 tag
.addInCanonTag(""); // bad format
448 describe("::addInvolvesTag", () => {
449 it("[[Call]] does nothing if called with no arguments", () => {
450 const tag
= new Tag("ConceptualTag");
451 tag
.addInvolvesTag();
452 assertEquals([...tag
.involvesTags()], []);
455 it("[[Call]] adds the provided tags", () => {
456 const involved
= new Tag();
458 const involved2
= new Tag();
460 const tag
= new Tag("ConceptualTag");
461 tag
.addInvolvesTag(involved
, involved2
);
463 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
464 [involved
.identifier
, involved2
.identifier
],
468 it("[[Call]] returns this", () => {
469 const tag
= new Tag("ConceptualTag");
470 assertStrictEquals(tag
.addInvolvesTag(), tag
);
473 it("[[Call]] throws when this is not a conceptual tag", () => {
474 const involved
= new Tag();
477 new Tag().addInvolvesTag(involved
);
481 it("[[Call]] throws when this is a relationship tag and provided with a non‐involvable tag", () => {
482 const notInvolved
= new Tag();
483 notInvolved
.persist();
484 const tag
= new Tag("RelationshipTag");
486 tag
.addInvolvesTag(notInvolved
);
490 it("[[Call]] throws when adding a non‐persisted tag", () => {
491 const tag
= new Tag("ConceptualTag");
493 tag
.addInvolvesTag(new Tag());
497 it("[[Call]] throws when adding an unrecognized identifier", () => {
498 const tag
= new Tag("ConceptualTag");
500 tag
.addInvolvesTag("000-0000"); // not persisted
503 tag
.addInvolvesTag(""); // bad format
508 // `::altLabels` is tested by `::addAltLabel`.
510 describe("::authorityName", () => {
511 it("[[Get]] returns the authority name of the tag system", () => {
513 new Tag().authorityName
,
514 system
.authorityName
,
519 // `::broaderTags` is tested by `::addBroaderTag`.
521 describe("::broaderTransitiveTags", () => {
522 it("[[Call]] returns broader tags transitively", () => {
523 const superBroad
= new Tag();
524 superBroad
.persist();
525 const broad
= new Tag();
526 broad
.addBroaderTag(superBroad
);
528 const tag
= new Tag();
529 tag
.addBroaderTag(broad
);
531 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
532 [broad
.identifier
, superBroad
.identifier
],
536 it("[[Call]] cannot recurse infinitely", () => {
537 const tag
= new Tag();
539 const broad
= new Tag();
540 broad
.addBroaderTag(tag
);
542 tag
.addBroaderTag(broad
);
545 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
546 [broad
.identifier
, tag
.identifier
],
551 describe("::deleteAltLabel", () => {
552 it("[[Call]] does nothing if called with no arguments", () => {
553 const tag
= new Tag();
554 tag
.addAltLabel("etaoin");
555 tag
.deleteAltLabel();
557 Array
.from(tag
.altLabels(), ($) => ({ ...$ })),
558 [{ "@value": "etaoin" }],
562 it("[[Call]] deletes only the provided hidden labels", () => {
563 const tag
= new Tag();
567 { "@value": "three", "@language": "en" },
573 { "@value": "three", "@language": "en" },
574 { "@value": "four", "@language": "en" },
577 Array
.from(tag
.altLabels(), ($) => ({ ...$ })),
578 [{ "@value": "four" }],
582 it("[[Call]] returns this", () => {
583 const tag
= new Tag();
584 assertStrictEquals(tag
.deleteAltLabel(), tag
);
588 describe("::deleteBroaderTag", () => {
589 it("[[Call]] does nothing if called with no arguments", () => {
590 const broader
= new Tag();
592 const tag
= new Tag();
593 tag
.addBroaderTag(broader
);
594 tag
.deleteBroaderTag();
596 Array
.from(tag
.broaderTags(), ($) => $.identifier
),
597 [broader
.identifier
],
601 it("[[Call]] deletes only the provided broader tags", () => {
602 const superBroader
= new Tag();
603 superBroader
.persist();
604 const broader
= new Tag();
605 broader
.addBroaderTag(superBroader
);
607 const broader2
= new Tag();
608 broader2
.addBroaderTag(superBroader
);
610 const tag
= new Tag();
611 tag
.addBroaderTag(broader
, broader2
);
612 tag
.deleteBroaderTag(broader
, superBroader
, "000-0000", "");
614 Array
.from(tag
.broaderTags(), ($) => $.identifier
),
615 [broader2
.identifier
],
619 it("[[Call]] returns this", () => {
620 const tag
= new Tag();
621 assertStrictEquals(tag
.deleteBroaderTag(), tag
);
625 describe("::deleteHiddenLabel", () => {
626 it("[[Call]] does nothing if called with no arguments", () => {
627 const tag
= new Tag();
628 tag
.addHiddenLabel("etaoin");
629 tag
.deleteHiddenLabel();
631 Array
.from(tag
.hiddenLabels(), ($) => ({ ...$ })),
632 [{ "@value": "etaoin" }],
636 it("[[Call]] deletes only the provided alternative labels", () => {
637 const tag
= new Tag();
641 { "@value": "three", "@language": "en" },
644 tag
.deleteHiddenLabel(
647 { "@value": "three", "@language": "en" },
648 { "@value": "four", "@language": "en" },
651 Array
.from(tag
.hiddenLabels(), ($) => ({ ...$ })),
652 [{ "@value": "four" }],
656 it("[[Call]] returns this", () => {
657 const tag
= new Tag();
658 assertStrictEquals(tag
.deleteHiddenLabel(), tag
);
662 describe("::deleteInCanonTag", () => {
663 it("[[Call]] does nothing if called with no arguments", () => {
664 const canon
= new Tag("CanonTag");
666 const tag
= new Tag("EntityTag");
667 tag
.addInCanonTag(canon
);
668 tag
.deleteInCanonTag();
670 Array
.from(tag
.inCanonTags(), ($) => $.identifier
),
675 it("[[Call]] deletes only the provided canon tags", () => {
676 const canon
= new Tag("CanonTag");
678 const canon2
= new Tag("CanonTag");
680 const tag
= new Tag("EntityTag");
681 tag
.addInCanonTag(canon
, canon2
);
682 tag
.deleteInCanonTag(canon
, "000-0000", "");
684 Array
.from(tag
.inCanonTags(), ($) => $.identifier
),
689 it("[[Call]] returns this", () => {
690 const tag
= new Tag("EntityTag");
691 assertStrictEquals(tag
.deleteInCanonTag(), tag
);
695 describe("::deleteInvolvesTag", () => {
696 it("[[Call]] does nothing if called with no arguments", () => {
697 const involved
= new Tag();
699 const tag
= new Tag("ConceptualTag");
700 tag
.addInvolvesTag(involved
);
701 tag
.deleteInvolvesTag();
703 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
704 [involved
.identifier
],
708 it("[[Call]] deletes only the provided involved tags", () => {
709 const character
= new Tag("CharacterTag");
711 const involved
= new Tag("RelationshipTag");
712 involved
.addInvolvesTag(character
);
714 const involved2
= new Tag("RelationshipTag");
715 involved2
.addInvolvesTag(character
);
717 const tag
= new Tag("RelationshipTag");
718 tag
.addInvolvesTag(involved
, involved2
);
719 tag
.deleteInvolvesTag(involved
, character
, "000-0000", "");
721 Array
.from(tag
.involvesTags(), ($) => $.identifier
),
722 [involved2
.identifier
],
726 it("[[Call]] returns this", () => {
727 const tag
= new Tag("ConceptualTag");
728 assertStrictEquals(tag
.deleteInvolvesTag(), tag
);
732 describe("::hasInCanonTags", () => {
733 it("[[Call]] yields the persisted tags which have this tag in canon", () => {
734 const canon
= new Tag("CanonTag");
736 const entity
= new Tag("EntityTag");
737 entity
.addInCanonTag(canon
);
739 const entity2
= new Tag("EntityTag");
740 entity2
.addInCanonTag(canon
);
742 const tag
= Tag
.fromIdentifier(canon
.identifier
); // reload
744 Array
.from(tag
.hasInCanonTags(), ($) => $.identifier
),
745 [entity
.identifier
, entity2
.identifier
],
750 // `::hiddenLabels` is tested by `::addHiddenLabel`.
752 // `::identifier` is tested by a `.fromIdentifier`.
754 // `::inCanonTags` is tested by `::addInCanonTag`.
756 describe("::involvedInTags", () => {
757 it("[[Call]] yields the persisted tags which involve this tag", () => {
758 const involved
= new Tag();
760 const conceptual
= new Tag("ConceptualTag");
761 conceptual
.addInvolvesTag(involved
);
762 conceptual
.persist();
763 const conceptual2
= new Tag("ConceptualTag");
764 conceptual2
.addInvolvesTag(involved
);
765 conceptual2
.persist();
766 const tag
= Tag
.fromIdentifier(involved
.identifier
); // reload
768 Array
.from(tag
.involvedInTags(), ($) => $.identifier
),
769 [conceptual
.identifier
, conceptual2
.identifier
],
774 // `::involvesTags` is tested by `::addInvolvesTag`.
776 // `::iri` is tested by a `.fromIRI`.
778 // `::iriSpace` is tested by a `.fromIRI`.
780 // `::kind` is tested by the constructor.
782 describe("::narrowerTags", () => {
783 it("[[Call]] yields the persisted tags which are narrower than this tag", () => {
784 const broader
= new Tag();
786 const narrower
= new Tag();
787 narrower
.addBroaderTag(broader
);
789 const narrower2
= new Tag();
790 narrower2
.addBroaderTag(broader
);
792 const tag
= Tag
.fromIdentifier(broader
.identifier
); // reload
794 Array
.from(tag
.narrowerTags(), ($) => $.identifier
),
795 [narrower
.identifier
, narrower2
.identifier
],
800 describe("::narrowerTransitiveTags", () => {
801 it("[[Call]] returns narrower tags transitively", () => {
802 const broad
= new Tag();
804 const narrow
= new Tag();
805 narrow
.addBroaderTag(broad
);
807 const superNarrow
= new Tag();
808 superNarrow
.addBroaderTag(narrow
);
809 superNarrow
.persist();
810 const tag
= Tag
.fromIdentifier(broad
.identifier
); // reload
813 tag
.narrowerTransitiveTags(),
816 [narrow
.identifier
, superNarrow
.identifier
],
820 it("[[Call]] cannot recurse infinitely", () => {
821 const tag
= new Tag();
823 const broad
= new Tag();
824 broad
.addBroaderTag(tag
);
826 tag
.addBroaderTag(broad
);
829 Array
.from(tag
.broaderTransitiveTags(), ($) => $.identifier
),
830 [broad
.identifier
, tag
.identifier
],
835 describe("::persist", () => {
836 it("[[Call]] returns an object with expected properties if there were changes", () => {
837 const tag
= new Tag();
838 const activity
= tag
.persist();
843 "https://ns.1024.gdn/Tagging/discovery.context.jsonld",
848 assertArrayIncludes(activity
["@type"], ["TagActivity"]);
849 assert("endTime" in activity
);
852 it("[[Call]] returns a Create activity with a type predicate for new objects", () => {
853 const activity
= new Tag().persist();
854 assertEquals(activity
["@type"], ["TagActivity", "Create"]);
855 assertArrayIncludes(activity
.states
, [{
861 it("[[Call]] returns an Update activity for old objects", () => {
862 const tag
= new Tag();
864 tag
.prefLabel
= "etaoin";
865 const activity
= tag
.persist();
866 assertEquals(activity
["@type"], ["TagActivity", "Update"]);
869 it("[[Call]] states and unstates changes", () => {
870 const broader1
= new Tag();
872 const broader2
= new Tag();
874 const tag
= new Tag();
875 tag
.addBroaderTag(broader1
);
877 tag
.prefLabel
= "etaoin";
878 tag
.deleteBroaderTag(broader1
);
879 tag
.addBroaderTag(broader2
);
880 const activity
= tag
.persist();
881 assertObjectMatch(activity
, {
883 { predicate
: "prefLabel", object
: { "@value": "" } },
884 { predicate
: "broader", object
: broader1
.iri
},
887 { predicate
: "prefLabel", object
: { "@value": "etaoin" } },
888 { predicate
: "broader", object
: broader2
.iri
},
893 it("[[Call]] doesn’t state if there are no additions", () => {
894 const tag
= new Tag();
895 tag
.addAltLabel("etaoin");
897 tag
.deleteAltLabel("etaoin");
898 const activity
= tag
.persist();
899 assertFalse("state" in activity
);
902 it("[[Call]] doesn’t unstate if there are no removals", () => {
903 const tag
= new Tag();
905 tag
.addAltLabel("etaoin");
906 const activity
= tag
.persist();
907 assertFalse("unstate" in activity
);
910 it("[[Call]] returns null if no meaningful changes were made", () => {
911 const tag
= new Tag();
913 const activity
= tag
.persist();
914 assertStrictEquals(activity
, null);
917 it("[[Call]] returns undefined for a silent persist", () => {
918 const broader
= new Tag();
920 const tag
= new Tag();
921 tag
.prefLabel
= "etaoin";
922 tag
.addBroaderTag(broader
);
923 assertStrictEquals(tag
.persist(true), undefined);
927 describe("::prefLabel", () => {
928 it("[[Set]] sets the preferred label", () => {
929 const tag
= new Tag();
930 tag
.prefLabel
= "one";
931 assertEquals({ ...tag
.prefLabel
}, { "@value": "one" });
932 tag
.prefLabel
= { "@value": "two" };
933 assertEquals({ ...tag
.prefLabel
}, { "@value": "two" });
934 tag
.prefLabel
= { "@value": "three", "@language": "en" };
936 { ...tag
.prefLabel
},
937 { "@value": "three", "@language": "en" },
942 // `::tagURI` is tested by a `.fromTagURI`.
944 describe("::taggingEntity", () => {
945 it("[[Get]] returns the tagging entity of the tag system", () => {
947 new Tag().taggingEntity
,
948 system
.taggingEntity
,
953 describe("::toString", () => {
954 it("[[Get]] returns the string value of the preferred label", () => {
955 const tag
= new Tag();
956 tag
.prefLabel
= { "@value": "etaoin", "@language": "zxx" };
957 assertStrictEquals(tag
.toString(), "etaoin");
961 // `::[Storage.toObject]` is tested by `::persist`.
964 describe("::authorityName", () => {
965 it("[[Get]] returns the authority name", () => {
966 const system
= new TagSystem("etaoin.example", "1972-12-31");
967 assertStrictEquals(system
.authorityName
, "etaoin.example");
971 describe("::authorityName", () => {
972 it("[[Get]] returns the date", () => {
973 const system
= new TagSystem("etaoin.example", "1972-12-31");
974 assertStrictEquals(system
.date
, "1972-12-31");
978 describe("::identifiers", () => {
979 it("[[Get]] yields the extant entities", () => {
980 const system
= new TagSystem("etaoin.example", "1972-12-31");
981 const tags
= new Set(function* () {
984 // Generate 5 tags and remember their identifiers.
985 const tag
= new system
.Tag();
987 yield tag
.identifier
;
991 new Set(Array
.from(system
.entities(), ($) => $.identifier
)),
997 describe("::identifier", () => {
998 it("[[Get]] returns the identifier", () => {
999 const system
= new TagSystem("etaoin.example", "1972-12-31");
1000 assertStrictEquals(system
.identifier
, "");
1001 const system2
= new TagSystem(
1006 assertStrictEquals(system2
.identifier
, "etaoin");
1010 describe("::identifiers", () => {
1011 it("[[Get]] yields the identifiers in use", () => {
1012 const system
= new TagSystem("etaoin.example", "1972-12-31");
1013 const tags
= new Set(function* () {
1016 // Generate 5 tags and remember their identifiers.
1017 const tag
= new system
.Tag();
1019 yield tag
.identifier
;
1022 assertEquals(new Set(system
.identifiers()), tags
);
1026 describe("::iri", () => {
1027 it("[[Get]] returns the I·R·I", () => {
1028 const system
= new TagSystem("etaoin.example", "1972-12-31");
1031 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1033 const system2
= new TagSystem(
1040 "https://etaoin.example/tag:etaoin.example,1972-12-31:etaoin",
1045 describe("::iriSpace", () => {
1046 it("[[Get]] returns the I·R·I space", () => {
1047 const system
= new TagSystem("etaoin.example", "1972-12-31");
1050 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1052 const system2
= new TagSystem(
1059 "https://etaoin.example/tag:etaoin.example,1972-12-31:",
1064 describe("::tagURI", () => {
1065 it("[[Get]] returns the Tag U·R·I", () => {
1066 const system
= new TagSystem("etaoin.example", "1972-12-31");
1069 "tag:etaoin.example,1972-12-31:",
1071 const system2
= new TagSystem(
1078 "tag:etaoin.example,1972-12-31:etaoin",
1083 describe("::taggingEntity", () => {
1084 it("[[Get]] returns the tagging entity", () => {
1085 const system
= new TagSystem("etaoin.example", "1972-12-31");
1087 system
.taggingEntity
,
1088 "etaoin.example,1972-12-31",
This page took 0.16526 seconds and 3 git commands to generate.