From abd5d1025360c6a732b4adc818c9c2649af61603 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 26 Jul 2019 18:29:00 +0200 Subject: [PATCH] Add unit tests for "OC.Notification.hide()" MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Signed-off-by: Daniel Calviño Sánchez --- core/js/tests/specs/coreSpec.js | 56 +++++++++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index e4247c51e10..f8c0e64a426 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -1027,6 +1027,62 @@ describe('Core base tests', function() { expect($row.length).toEqual(1); }); }); + describe('hide', function() { + it('hides a temporary notification before its timeout expires', function() { + var hideCallback = sinon.spy(); + + var notification = OC.Notification.showTemporary(''); + + var $row = $('#testArea .toastify'); + expect($row.length).toEqual(1); + + OC.Notification.hide(notification, hideCallback); + + // Give time to the hide animation to finish + clock.tick(1000); + + $row = $('#testArea .toastify'); + expect($row.length).toEqual(0); + + expect(hideCallback.calledOnce).toEqual(true); + }); + it('hides a notification before its timeout expires', function() { + var hideCallback = sinon.spy(); + + var notification = OC.Notification.show('', {timeout: 10}); + + var $row = $('#testArea .toastify'); + expect($row.length).toEqual(1); + + OC.Notification.hide(notification, hideCallback); + + // Give time to the hide animation to finish + clock.tick(1000); + + $row = $('#testArea .toastify'); + expect($row.length).toEqual(0); + + expect(hideCallback.calledOnce).toEqual(true); + }); + it('hides a notification without timeout', function() { + var hideCallback = sinon.spy(); + + var notification = OC.Notification.show(''); + + var $row = $('#testArea .toastify'); + expect($row.length).toEqual(1); + + OC.Notification.hide(notification, hideCallback); + + // Give time to the hide animation to finish + clock.tick(1000); + + $row = $('#testArea .toastify'); + expect($row.length).toEqual(0); + + expect(hideCallback.calledOnce).toEqual(true); + }); + }); it('cumulates several notifications', function() { var $row1 = OC.Notification.showTemporary('One'); var $row2 = OC.Notification.showTemporary('Two', {timeout: 2}); -- 2.39.5