summaryrefslogtreecommitdiffstats
path: root/core/js/tests
diff options
context:
space:
mode:
authorChristoph Wurst <christoph@winzerhof-wurst.at>2020-02-07 11:02:45 +0100
committerChristoph Wurst <christoph@winzerhof-wurst.at>2020-04-06 17:19:57 +0200
commit8119e0b18ef4438e7da1279332a960ce8f749835 (patch)
tree0ef2e67d2c7adc8a90af9226f279608f3a61ab7e /core/js/tests
parent01a70e5d0f6f369fefd510379994e7f465289421 (diff)
downloadnextcloud-server-8119e0b18ef4438e7da1279332a960ce8f749835.tar.gz
nextcloud-server-8119e0b18ef4438e7da1279332a960ce8f749835.zip
Inline usages of OCP.Toast in bundled files
Signed-off-by: Christoph Wurst <christoph@winzerhof-wurst.at>
Diffstat (limited to 'core/js/tests')
-rw-r--r--core/js/tests/specs/coreSpec.js61
1 files changed, 24 insertions, 37 deletions
diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js
index c7399ea5d3e..3aecc120ad5 100644
--- a/core/js/tests/specs/coreSpec.js
+++ b/core/js/tests/specs/coreSpec.js
@@ -677,7 +677,6 @@ describe('Core base tests', function() {
});
});
describe('Notifications', function() {
- var showSpy;
var showHtmlSpy;
var clock;
@@ -694,68 +693,56 @@ describe('Core base tests', function() {
beforeEach(function() {
clock = sinon.useFakeTimers();
- showSpy = sinon.spy(OCP.Toast, 'message');
-
- $('#testArea').append('<div id="content"></div>');
});
afterEach(function() {
- showSpy.restore();
// jump past animations
clock.tick(10000);
clock.restore();
- $('#testArea .toastify').remove();
+ $('body .toastify').remove();
});
describe('showTemporary', function() {
it('shows a plain text notification with default timeout', function() {
OC.Notification.showTemporary('My notification test');
- expect(showSpy.calledOnce).toEqual(true);
- expect(showSpy.firstCall.args[0]).toEqual('My notification test');
- //expect(showSpy.firstCall.args[1]).toEqual({isHTML: false, timeout: 7});
-
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
expect(getNotificationText($row)).toEqual('My notification test');
});
it('shows a HTML notification with default timeout', function() {
OC.Notification.showTemporary('<a>My notification test</a>', { isHTML: true });
- expect(showSpy.calledOnce).toEqual(true);
- expect(showSpy.firstCall.args[0]).toEqual('<a>My notification test</a>');
- expect(showSpy.firstCall.args[1].isHTML).toEqual(true)
-
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
expect(getNotificationText($row)).toEqual('<a>My notification test</a>');
});
it('hides itself after 7 seconds', function() {
OC.Notification.showTemporary('');
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
// travel in time +7000 milliseconds
clock.tick(7500);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
});
it('hides itself after a given time', function() {
OC.Notification.showTemporary('', {timeout: 10});
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
// travel in time +7000 milliseconds
clock.tick(7500);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(1);
// travel in time another 4000 milliseconds
clock.tick(4000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
});
});
@@ -763,24 +750,24 @@ describe('Core base tests', function() {
it('hides itself after a given time', function() {
OC.Notification.show('', {timeout: 10});
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
clock.tick(11500);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
});
it('does not hide itself if no timeout given to show', function() {
OC.Notification.show('');
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
// travel in time +1000 seconds
clock.tick(1000000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(1);
});
});
@@ -788,24 +775,24 @@ describe('Core base tests', function() {
it('hides itself after a given time', function() {
OC.Notification.showHtml('<p></p>', {timeout: 10});
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
clock.tick(11500);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
});
it('does not hide itself if no timeout given to show', function() {
OC.Notification.showHtml('<p></p>');
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
// travel in time +1000 seconds
clock.tick(1000000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(1);
});
});
@@ -815,7 +802,7 @@ describe('Core base tests', function() {
var notification = OC.Notification.showTemporary('');
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
OC.Notification.hide(notification, hideCallback);
@@ -823,7 +810,7 @@ describe('Core base tests', function() {
// Give time to the hide animation to finish
clock.tick(1000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
expect(hideCallback.calledOnce).toEqual(true);
@@ -833,7 +820,7 @@ describe('Core base tests', function() {
var notification = OC.Notification.show('', {timeout: 10});
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
OC.Notification.hide(notification, hideCallback);
@@ -841,7 +828,7 @@ describe('Core base tests', function() {
// Give time to the hide animation to finish
clock.tick(1000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
expect(hideCallback.calledOnce).toEqual(true);
@@ -851,7 +838,7 @@ describe('Core base tests', function() {
var notification = OC.Notification.show('');
- var $row = $('#testArea .toastify');
+ var $row = $('body .toastify');
expect($row.length).toEqual(1);
OC.Notification.hide(notification, hideCallback);
@@ -859,7 +846,7 @@ describe('Core base tests', function() {
// Give time to the hide animation to finish
clock.tick(1000);
- $row = $('#testArea .toastify');
+ $row = $('body .toastify');
expect($row.length).toEqual(0);
expect(hideCallback.calledOnce).toEqual(true);
@@ -870,7 +857,7 @@ describe('Core base tests', function() {
var $row2 = OC.Notification.showTemporary('Two', {timeout: 2});
var $row3 = OC.Notification.showTemporary('Three');
- var $el = $('#testArea');
+ var $el = $('body');
var $rows = $el.find('.toastify');
expect($rows.length).toEqual(3);
@@ -890,7 +877,7 @@ describe('Core base tests', function() {
var $row1 = OC.Notification.show('One');
var $row2 = OC.Notification.show('Two');
- var $el = $('#testArea');
+ var $el = $('body');
var $rows = $el.find('.toastify');
expect($rows.length).toEqual(2);