Skip to content
Merged
Changes from 1 commit
Commits
Show all changes
17 commits
Select commit Hold shift + click to select a range
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
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 <[email protected]>
  • Loading branch information
danxuliu committed Mar 20, 2018
commit fcef15af801b4e88f857b5621ad028abdeebec28
15 changes: 11 additions & 4 deletions core/js/tests/specs/sharedialogviewSpec.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ describe('OC.Share.ShareDialogView', function() {
var saveLinkShareStub;

var fetchStub;
var notificationStub;

var configModel;
var shareModel;
Expand Down Expand Up @@ -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();
Expand Down Expand Up @@ -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() {
Expand Down