From 2b1c80ea3f742014ea7e45d6a5408fd94a5d80b4 Mon Sep 17 00:00:00 2001 From: =?utf8?q?Daniel=20Calvi=C3=B1o=20S=C3=A1nchez?= Date: Fri, 26 Jul 2019 17:40:44 +0200 Subject: [PATCH] Check number of elements instead of if the jQuery object is defined MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit Tje jQuery object created through "$('#testArea .toastify')" will be always defined even if no elements were found, so the check does not really work; instead, it should be checked the number of elements found. Signed-off-by: Daniel Calviño Sánchez --- core/js/tests/specs/coreSpec.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/core/js/tests/specs/coreSpec.js b/core/js/tests/specs/coreSpec.js index 52099bdb26c..87b39da1f14 100644 --- a/core/js/tests/specs/coreSpec.js +++ b/core/js/tests/specs/coreSpec.js @@ -935,7 +935,7 @@ describe('Core base tests', function() { //expect(showSpy.firstCall.args[1]).toEqual({isHTML: false, timeout: 7}); var $row = $('#testArea .toastify'); - expect($row).toBeDefined(); + expect($row.length).toEqual(1); expect(getNotificationText($row)).toEqual('My notification test'); }); it('shows a HTML notification with default timeout', function() { @@ -946,14 +946,14 @@ describe('Core base tests', function() { expect(showSpy.firstCall.args[1].isHTML).toEqual(true) var $row = $('#testArea .toastify'); - expect($row).toBeDefined(); + expect($row.length).toEqual(1); expect(getNotificationText($row)).toEqual('My notification test'); }); it('hides itself after 7 seconds', function() { OC.Notification.showTemporary(''); var $row = $('#testArea .toastify'); - expect($row).toBeDefined(); + expect($row.length).toEqual(1); // travel in time +7000 milliseconds clock.tick(7500); @@ -967,7 +967,7 @@ describe('Core base tests', function() { OC.Notification.showTemporary('', {timeout: 10}); var $row = $('#testArea .toastify'); - expect($row).toBeDefined(); + expect($row.length).toEqual(1); clock.tick(11500); -- 2.39.5