summaryrefslogtreecommitdiffstats
path: root/core/js/tests
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2019-07-26 18:29:00 +0200
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2019-07-26 18:46:59 +0200
commitabd5d1025360c6a732b4adc818c9c2649af61603 (patch)
tree0c9fec328d621592f05c685439740f43c7cae9e5 /core/js/tests
parent03f2e8a10e7c900b7a66683798309010a9428b16 (diff)
downloadnextcloud-server-abd5d1025360c6a732b4adc818c9c2649af61603.tar.gz
nextcloud-server-abd5d1025360c6a732b4adc818c9c2649af61603.zip
Add unit tests for "OC.Notification.hide()"
Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
Diffstat (limited to 'core/js/tests')
-rw-r--r--core/js/tests/specs/coreSpec.js56
1 files changed, 56 insertions, 0 deletions
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});