]> Lady’s Gitweb - Etiquette/blobdiff - model.test.js
Always return (the same) objects for langstrings
[Etiquette] / model.test.js
index 15a2f54cfa955831457a64d8dcd215e486937ed4..3e9982a7a4fb513495204b5d80608e4d04f2c6a9 100644 (file)
@@ -105,13 +105,13 @@ describe("TagSystem", () => {
     });
 
     it("[[Construct]] defaults the preferred label to the empty string", () => {
-      assertStrictEquals(new Tag().prefLabel, "");
+      assertEquals({ ...new Tag().prefLabel }, { "@value": "" });
     });
 
     it("[[Construct]] correctly sets the preferred label to a simple string", () => {
-      assertStrictEquals(
-        new Tag("RelationshipTag", "Shadow, Me").prefLabel,
-        "Shadow, Me",
+      assertEquals(
+        { ...new Tag("RelationshipTag", "Shadow, Me").prefLabel },
+        { "@value": "Shadow, Me" },
       );
     });
 
@@ -187,7 +187,9 @@ describe("TagSystem", () => {
       });
 
       it("[[Call]] throws if passed an invalid I·R·I", () => {
-        assertThrows(() => {Tag.fromIRI(`bad iri`)});
+        assertThrows(() => {
+          Tag.fromIRI(`bad iri`);
+        });
       });
     });
 
@@ -295,13 +297,10 @@ describe("TagSystem", () => {
           { "@value": "three", "@language": "en" },
         );
         assertEquals(
-          Array.from(
-            tag.altLabels(),
-            ($) => typeof $ == "string" ? $ : { ...$ },
-          ),
+          Array.from(tag.altLabels(), ($) => ({ ...$ })),
           [
-            "one",
-            "two",
+            { "@value": "one" },
+            { "@value": "two" },
             { "@value": "three", "@language": "en" },
           ],
         );
@@ -371,13 +370,10 @@ describe("TagSystem", () => {
           { "@value": "three", "@language": "en" },
         );
         assertEquals(
-          Array.from(
-            tag.hiddenLabels(),
-            ($) => typeof $ == "string" ? $ : { ...$ },
-          ),
+          Array.from(tag.hiddenLabels(), ($) => ({ ...$ })),
           [
-            "one",
-            "two",
+            { "@value": "one" },
+            { "@value": "two" },
             { "@value": "three", "@language": "en" },
           ],
         );
@@ -553,7 +549,10 @@ describe("TagSystem", () => {
         const tag = new Tag();
         tag.addAltLabel("etaoin");
         tag.deleteAltLabel();
-        assertEquals([...tag.altLabels()], ["etaoin"]);
+        assertEquals(
+          Array.from(tag.altLabels(), ($) => ({ ...$ })),
+          [{ "@value": "etaoin" }],
+        );
       });
 
       it("[[Call]] deletes only the provided hidden labels", () => {
@@ -570,7 +569,10 @@ describe("TagSystem", () => {
           { "@value": "three", "@language": "en" },
           { "@value": "four", "@language": "en" },
         );
-        assertEquals([...tag.altLabels()], ["four"]);
+        assertEquals(
+          Array.from(tag.altLabels(), ($) => ({ ...$ })),
+          [{ "@value": "four" }],
+        );
       });
 
       it("[[Call]] returns this", () => {
@@ -621,7 +623,10 @@ describe("TagSystem", () => {
         const tag = new Tag();
         tag.addHiddenLabel("etaoin");
         tag.deleteHiddenLabel();
-        assertEquals([...tag.hiddenLabels()], ["etaoin"]);
+        assertEquals(
+          Array.from(tag.hiddenLabels(), ($) => ({ ...$ })),
+          [{ "@value": "etaoin" }],
+        );
       });
 
       it("[[Call]] deletes only the provided alternative labels", () => {
@@ -638,7 +643,10 @@ describe("TagSystem", () => {
           { "@value": "three", "@language": "en" },
           { "@value": "four", "@language": "en" },
         );
-        assertEquals([...tag.hiddenLabels()], ["four"]);
+        assertEquals(
+          Array.from(tag.hiddenLabels(), ($) => ({ ...$ })),
+          [{ "@value": "four" }],
+        );
       });
 
       it("[[Call]] returns this", () => {
@@ -916,9 +924,9 @@ describe("TagSystem", () => {
       it("[[Set]] sets the preferred label", () => {
         const tag = new Tag();
         tag.prefLabel = "one";
-        assertStrictEquals(tag.prefLabel, "one");
+        assertEquals({ ...tag.prefLabel }, { "@value": "one" });
         tag.prefLabel = { "@value": "two" };
-        assertStrictEquals(tag.prefLabel, "two");
+        assertEquals({ ...tag.prefLabel }, { "@value": "two" });
         tag.prefLabel = { "@value": "three", "@language": "en" };
         assertEquals(
           { ...tag.prefLabel },
This page took 0.06562 seconds and 4 git commands to generate.