From 5bd0ffa56ce0d77670d84303d3dcf4de2287acf5 Mon Sep 17 00:00:00 2001 From: Theresa Gresch Date: Fri, 9 Aug 2019 13:31:56 +0200 Subject: [PATCH] Add tests for album model --- frontend/tests/unit/model/album_test.js | 28 ++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/frontend/tests/unit/model/album_test.js b/frontend/tests/unit/model/album_test.js index 2427736df..b48c33272 100644 --- a/frontend/tests/unit/model/album_test.js +++ b/frontend/tests/unit/model/album_test.js @@ -10,7 +10,7 @@ const postLikeEntity = [ ]; mock.onPost("foo").reply(201, postLikeEntity); -describe("model/album", () => { +describe.only("model/album", () => { it("should get album entity name", () => { const values = {id: 5, AlbumName: "Christmas 2019", AlbumSlug: "christmas-2019"}; const album = new Album(values); @@ -71,6 +71,32 @@ describe("model/album", () => { assert.equal(result, "albums"); }); + it("should like album", () => { + const values = {id: 5, AlbumName: "Christmas 2019", AlbumSlug: "christmas-2019", AlbumFavorite: false}; + const album = new Album(values); + assert.equal(album.AlbumFavorite, false); + album.like(); + assert.equal(album.AlbumFavorite, true); + }); + + it("should unlike album", () => { + const values = {id: 5, AlbumName: "Christmas 2019", AlbumSlug: "christmas-2019", AlbumFavorite: true}; + const album = new Album(values); + assert.equal(album.AlbumFavorite, true); + album.unlike(); + assert.equal(album.AlbumFavorite, false); + }); + + it("should toggle like", () => { + const values = {id: 5, AlbumName: "Christmas 2019", AlbumSlug: "christmas-2019", AlbumFavorite: true}; + const album = new Album(values); + assert.equal(album.AlbumFavorite, true); + album.toggleLike(); + assert.equal(album.AlbumFavorite, false); + album.toggleLike(); + assert.equal(album.AlbumFavorite, true); + }); + it("should toggle like", () => { Api.post('foo', postLikeEntity).then( (response) => {