From 192812b06b55a6f80bcebb16a7737b6f5a360f16 Mon Sep 17 00:00:00 2001 From: Heiko Kernbach Date: Fri, 25 Apr 2014 09:31:42 +0200 Subject: [PATCH] notification completely tested --- .../test/specs/views/notificationViewSpec.js | 52 +++++++++++++++++++ 1 file changed, 52 insertions(+) diff --git a/js/apps/system/aardvark/test/specs/views/notificationViewSpec.js b/js/apps/system/aardvark/test/specs/views/notificationViewSpec.js index 0b0963d6fe..36d657f1d2 100644 --- a/js/apps/system/aardvark/test/specs/views/notificationViewSpec.js +++ b/js/apps/system/aardvark/test/specs/views/notificationViewSpec.js @@ -78,7 +78,59 @@ expect($('#notification_menu').is(":visible")).toBeFalsy(); }); + it("renderNotifications function with collection length 0", function () { + jQueryDummy = { + html: function () { + }, + text: function () { + }, + removeClass: function() { + }, + hide: function () { + } + }; + spyOn(jQueryDummy, "html"); + spyOn(jQueryDummy, "text"); + spyOn(jQueryDummy, "removeClass"); + spyOn(jQueryDummy, "hide"); + + spyOn(window, "$").andReturn( + jQueryDummy + ); + + view.renderNotifications(); + expect(jQueryDummy.text).toHaveBeenCalled(); + expect(jQueryDummy.removeClass).toHaveBeenCalled(); + expect(jQueryDummy.hide).toHaveBeenCalled(); + expect(jQueryDummy.html).toHaveBeenCalled(); + }); + + it("renderNotifications function with collection length > 0", function () { + view.collection.add(fakeNotification); + + jQueryDummy = { + html: function () { + }, + text: function () { + }, + addClass: function() { + } + }; + + spyOn(jQueryDummy, "html"); + spyOn(jQueryDummy, "text"); + spyOn(jQueryDummy, "addClass"); + + spyOn(window, "$").andReturn( + jQueryDummy + ); + + view.renderNotifications(); + expect(jQueryDummy.text).toHaveBeenCalled(); + expect(jQueryDummy.addClass).toHaveBeenCalled(); + expect(jQueryDummy.html).toHaveBeenCalled(); + }); });