summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-19 14:12:06 +0100
committerDaniel Calviño Sánchez <danxuliu@gmail.com>2018-03-20 19:09:04 +0100
commitfcef15af801b4e88f857b5621ad028abdeebec28 (patch)
tree20737e9175a4f63c6f54b6ba853d47be8140b794
parentd6062195766fc21b53be1990e6633da7da58d732 (diff)
downloadnextcloud-server-fcef15af801b4e88f857b5621ad028abdeebec28.tar.gz
nextcloud-server-fcef15af801b4e88f857b5621ad028abdeebec28.zip
Move stub setup outside the test method
Stubs should be restored outside the test method in which they are used to ensure that they are properly restored no matter the result of the test (for example, if an exception is thrown). Besides that, this will make possible to reuse the stub in other sibling tests without having to explicitly setup it in them. Signed-off-by: Daniel Calviño Sánchez <danxuliu@gmail.com>
-rw-r--r--core/js/tests/specs/sharedialogviewSpec.js15
1 files changed, 11 insertions, 4 deletions
diff --git a/core/js/tests/specs/sharedialogviewSpec.js b/core/js/tests/specs/sharedialogviewSpec.js
index 491a52851b2..63434c3b1ee 100644
--- a/core/js/tests/specs/sharedialogviewSpec.js
+++ b/core/js/tests/specs/sharedialogviewSpec.js
@@ -30,7 +30,6 @@ describe('OC.Share.ShareDialogView', function() {
var saveLinkShareStub;
var fetchStub;
- var notificationStub;
var configModel;
var shareModel;
@@ -473,6 +472,16 @@ describe('OC.Share.ShareDialogView', function() {
});
});
describe('autocompletion of users', function() {
+ var showNotificationStub;
+
+ beforeEach(function() {
+ showNotificationStub = sinon.stub(OC.Notification, 'show');
+ });
+
+ afterEach(function() {
+ showNotificationStub.restore();
+ });
+
describe('triggers autocomplete display and focus with data when ajax search succeeds', function () {
it('users', function () {
dialog.render();
@@ -1474,12 +1483,10 @@ describe('OC.Share.ShareDialogView', function() {
});
it('throws a notification when the ajax search lookup fails', function () {
- notificationStub = sinon.stub(OC.Notification, 'show');
dialog.render();
dialog.autocompleteHandler({term: 'bob'}, sinon.stub());
fakeServer.requests[0].respond(500);
- expect(notificationStub.calledOnce).toEqual(true);
- notificationStub.restore();
+ expect(showNotificationStub.calledOnce).toEqual(true);
});
describe('renders the autocomplete elements', function() {