diff --git a/frontend/tests/unit/common/config_test.js b/frontend/tests/unit/common/config_test.js index 2be34160d..ac842e51b 100644 --- a/frontend/tests/unit/common/config_test.js +++ b/frontend/tests/unit/common/config_test.js @@ -128,15 +128,9 @@ describe("common/config", () => { }); assert.equal(config.values.people[0].Name, "New Name"); config.onPeople(".deleted", { - entities: [ - { - UID: "abc123", - Name: "New Name", - Keywords: ["New", "Name"], - }, - ], + entities: ["abc123"], }); - assert.equal(config.values.people[0].Name, "New Name"); + assert.empty(config.values.people); }); it("should return if language is rtl", () => { diff --git a/frontend/tests/unit/common/util_test.js b/frontend/tests/unit/common/util_test.js index 3d4e8f76c..b6ef0abd3 100644 --- a/frontend/tests/unit/common/util_test.js +++ b/frontend/tests/unit/common/util_test.js @@ -53,4 +53,8 @@ describe("common/util", () => { const result = Util.truncate("teststring for mocha", 5, "ng"); assert.equal(result, "tesng"); }); + it("should encode html", () => { + const result = Util.encodeHTML("Micha & Theresa > < 'Lilly'"); + assert.equal(result, "Micha & Theresa > < 'Lilly'"); + }); }); diff --git a/frontend/tests/unit/fixtures.js b/frontend/tests/unit/fixtures.js index 9994d3ad7..bb37c5389 100644 --- a/frontend/tests/unit/fixtures.js +++ b/frontend/tests/unit/fixtures.js @@ -333,6 +333,8 @@ Mock.onPost("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, m Mock.onDelete("api/v1/subjects/s123ghytrfggd/like").reply(200, { status: "ok" }, mockHeaders); Mock.onGet("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders); Mock.onPost("api/v1/config/options").reply(200, { success: "ok" }, mockHeaders); +Mock.onPost("api/v1/albums").reply(200, { success: "ok" }, mockHeaders); + //Mock.onPost().reply(200); //Mock.onDelete().reply(200); diff --git a/frontend/tests/unit/model/face_test.js b/frontend/tests/unit/model/face_test.js index b76b79bf8..cb978a830 100644 --- a/frontend/tests/unit/model/face_test.js +++ b/frontend/tests/unit/model/face_test.js @@ -72,7 +72,11 @@ describe("model/face", () => { assert.equal(result, "/api/v1/t/7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1/public/xyz"); - const values2 = { ID: "f123ghytrfggd", Samples: 5, Thumb: "7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1" }; + const values2 = { + ID: "f123ghytrfggd", + Samples: 5, + Thumb: "7ca759a2b788cc5bcc08dbbce9854ff94a2f94d1", + }; const face2 = new Face(values2); const result2 = face2.thumbnailUrl(); @@ -105,6 +109,21 @@ describe("model/face", () => { assert.equal(face.Hidden, true); }); + it("should toggle hidden", () => { + const values = { + ID: "f123ghytrfggd", + Samples: 5, + CreatedAt: "2012-07-08T14:45:39Z", + Hidden: true, + }; + const face = new Face(values); + assert.equal(face.Hidden, true); + face.toggleHidden(); + assert.equal(face.Hidden, false); + face.toggleHidden(); + assert.equal(face.Hidden, true); + }); + it("should return batch size", () => { assert.equal(Face.batchSize(), 24); }); diff --git a/frontend/tests/unit/model/photo_test.js b/frontend/tests/unit/model/photo_test.js index f3f185551..e4a71cda0 100644 --- a/frontend/tests/unit/model/photo_test.js +++ b/frontend/tests/unit/model/photo_test.js @@ -1386,6 +1386,7 @@ describe("model/photo", () => { ], }; const photo = new Photo(values); + photo.Title = "New Title"; photo .update() .then((response) => { @@ -1395,5 +1396,63 @@ describe("model/photo", () => { .catch((error) => { done(error); }); + assert.equal(photo.Title, "New Title"); + }); + + it("should test get Markers", () => { + const values = { + ID: 10, + UID: "pqbemz8276mhtobh", + Lat: 1.1, + Lng: 3.3, + CameraID: 123, + Title: "Test Titel", + Description: "Super nice video", + Files: [ + { + UID: "fqbfk181n4ca5sud", + Name: "1980/01/superCuteKitten.mp4", + Primary: false, + Type: "mp4", + Hash: "1xxbgdt55", + }, + ], + }; + const photo = new Photo(values); + const result = photo.getMarkers(true); + assert.empty(result); + const values2 = { + ID: 10, + UID: "pqbemz8276mhtobh", + Lat: 1.1, + Lng: 3.3, + CameraID: 123, + Title: "Test Titel", + Description: "Super nice video", + Files: [ + { + UID: "fqbfk181n4ca5sud", + Name: "1980/01/superCuteKitten.mp4", + Primary: true, + Type: "mp4", + Hash: "1xxbgdt55", + Markers: [ + { + UID: "aaa123", + Invalid: false, + }, + { + UID: "bbb123", + Invalid: true, + }, + ], + }, + ], + }; + const photo2 = new Photo(values2); + const result2 = photo2.getMarkers(true); + assert.equal(result2.length, 1); + const result3 = photo2.getMarkers(false); + assert.equal(result3.length, 2); }); }); diff --git a/frontend/tests/unit/model/rest_test.js b/frontend/tests/unit/model/rest_test.js index 823c92b03..55e3b9ce1 100644 --- a/frontend/tests/unit/model/rest_test.js +++ b/frontend/tests/unit/model/rest_test.js @@ -65,6 +65,15 @@ describe("model/abstract", () => { assert.equal(album.Description, undefined); await album.save(); assert.equal(album.Description, "Test description"); + + const values2 = { Name: "Christmas 2019", Slug: "christmas-2019" }; + const album2 = new Album(values2); + album.Name = "Christmas 2020"; + assert.equal(album2.Description, undefined); + await album2.save().then((response) => { + assert.equal(response.success, "ok"); + }); + assert.equal(album2.Description, undefined); }); it("should remove album", async () => { diff --git a/frontend/tests/unit/model/subject_test.js b/frontend/tests/unit/model/subject_test.js index 3d91501b0..ee2bbebd5 100644 --- a/frontend/tests/unit/model/subject_test.js +++ b/frontend/tests/unit/model/subject_test.js @@ -200,6 +200,40 @@ describe("model/subject", () => { assert.equal(subject.Favorite, true); }); + it("show and hide subject", () => { + const values = { + UID: "s123ghytrfggd", + Type: "person", + Src: "manual", + Name: "Jane Doe", + Slug: "jane-doe", + Hidden: true, + }; + const subject = new Subject(values); + assert.equal(subject.Hidden, true); + subject.show(); + assert.equal(subject.Hidden, false); + subject.hide(); + assert.equal(subject.Hidden, true); + }); + + it("should toggle hidden", () => { + const values = { + UID: "s123ghytrfggd", + Type: "person", + Src: "manual", + Name: "Jane Doe", + Slug: "jane-doe", + Hidden: true, + }; + const subject = new Subject(values); + assert.equal(subject.Hidden, true); + subject.toggleHidden(); + assert.equal(subject.Hidden, false); + subject.toggleHidden(); + assert.equal(subject.Hidden, true); + }); + it("should return batch size", () => { assert.equal(Subject.batchSize(), 60); });