From 9112d3071181a3b6ab36764ce9bccd2fc2cad5f5 Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Fri, 9 Aug 2019 13:50:07 +0200 Subject: [PATCH] Add tests for photo model --- frontend/tests/unit/model/photo_test.js | 26 +++++++++++++++++++++++++ 1 file changed, 26 insertions(+) diff --git a/frontend/tests/unit/model/photo_test.js b/frontend/tests/unit/model/photo_test.js index 5bc570158..aa3bc1267 100644 --- a/frontend/tests/unit/model/photo_test.js +++ b/frontend/tests/unit/model/photo_test.js @@ -198,4 +198,30 @@ describe("model/photo", () => { assert.equal(result, "Photo"); }); + it("should like photo", () => { + const values = {ID: 5, PhotoTitle: "Crazy Cat", CountryName: "Africa", PhotoFavorite: false}; + const photo = new Photo(values); + assert.equal(photo.PhotoFavorite, false); + photo.like(); + assert.equal(photo.PhotoFavorite, true); + }); + + it("should unlike photo", () => { + const values = {ID: 5, PhotoTitle: "Crazy Cat", CountryName: "Africa", PhotoFavorite: true}; + const photo = new Photo(values); + assert.equal(photo.PhotoFavorite, true); + photo.unlike(); + assert.equal(photo.PhotoFavorite, false); + }); + + it("should toggle like", () => { + const values = {ID: 5, PhotoTitle: "Crazy Cat", CountryName: "Africa", PhotoFavorite: true}; + const photo = new Photo(values); + assert.equal(photo.PhotoFavorite, true); + photo.toggleLike(); + assert.equal(photo.PhotoFavorite, false); + photo.toggleLike(); + assert.equal(photo.PhotoFavorite, true); + }); + }); \ No newline at end of file