diff --git a/test/display-name-slug-editor.test.js b/test/display-name-slug-editor.test.js index 7b936a6..07161d8 100644 --- a/test/display-name-slug-editor.test.js +++ b/test/display-name-slug-editor.test.js @@ -61,17 +61,18 @@ describe('', function() { }); describe('component lifecycle', function() { - const getResourceUrlSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'getResourceUrl'); + let getResourceUrlSpy; const origin = 'https://www.test.com'; before(function() { + getResourceUrlSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'getResourceUrl'); wrapper = mount(); }); describe('componentDidMount', function() { after(function() { - getResourceUrlSpy.reset(); + getResourceUrlSpy.resetHistory(); }); it('should call getResourceUrl', function() { @@ -117,9 +118,10 @@ describe('', function() { let button; const onChangeSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'handleInputChange'); const undoNameChangeSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'undoNameChange'); - const warnURLChangeSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'warnURLChange'); + let warnURLChangeSpy; before(function() { + warnURLChangeSpy = sinon.spy(DisplayNameSlugEditor.prototype, 'warnURLChange'); wrapper = mount(); input = wrapper.find('input[type="text"]'); value = 'Lorem ipsum'; @@ -136,7 +138,7 @@ describe('', function() { expect(warnURLChangeSpy.calledOnce).to.be.true; expect(warnURLChangeSpy.calledWith(resource, value)).to.be.true; expect(warnURLChangeSpy.calledAfter(onChangeSpy)).to.be.true; - warnURLChangeSpy.reset(); + warnURLChangeSpy.resetHistory(); }); it('warns the user about URL changes', function() { @@ -159,7 +161,7 @@ describe('', function() { input.simulate('change', { target: { value: 'a new name' }}); expect(warnURLChangeSpy.calledOnce).to.be.true; expect(wrapper.state().warn).to.be.false; - warnURLChangeSpy.reset(); + warnURLChangeSpy.resetHistory(); }); it('does not warn the user about URL changes if the slug includes "untitled-organization"', function() { diff --git a/test/paginator.test.js b/test/paginator.test.js index 7a3c193..8ad438e 100644 --- a/test/paginator.test.js +++ b/test/paginator.test.js @@ -99,15 +99,16 @@ describe('Paginator', function() { describe('with props page, pageKey and router provided', function() { let wrapper; - const router = { push() {} }; - const spy = sinon.spy(router, 'push'); + const router = { + push: sinon.spy() + }; beforeEach(function() { wrapper = mount(); }); afterEach(function() { - spy.reset(); + router.push.resetHistory(); }); it('should start on page', function() { @@ -115,42 +116,39 @@ describe('Paginator', function() { }); it('should add pageKey to param onChange', function() { wrapper.find('#next').simulate('click'); - expect(Object.keys(spy.args[0][0].query)).to.include('testPage'); + expect(Object.keys(router.push.args[0][0].query)).to.include('testPage'); }); it('should go to the next page', function() { wrapper.find('#next').simulate('click'); - expect(spy.args[0][0].query.testPage).to.equal(6); + expect(router.push.args[0][0].query.testPage).to.equal(6); }); it('should go to the last page', function() { wrapper.find('#last').simulate('click'); - expect(spy.args[0][0].query.testPage).to.equal(10); + expect(router.push.args[0][0].query.testPage).to.equal(10); }); it('should go to the previous page', function() { wrapper.find('#previous').simulate('click'); - expect(spy.args[0][0].query.testPage).to.equal(4); + expect(router.push.args[0][0].query.testPage).to.equal(4); }); it('should go to the first page', function() { wrapper.find('#first').simulate('click'); - expect(spy.args[0][0].query.testPage).to.equal(1); + expect(router.push.args[0][0].query.testPage).to.equal(1); }); it('should go to a page selected', function() { wrapper.find('select').simulate('change', { target: { value: 3 }}); - expect(spy.args[0][0].query.testPage).to.equal(3); + expect(router.push.args[0][0].query.testPage).to.equal(3); }); }); describe('with onPageChange prop provided', function() { let wrapper; - const onPageChange = sinon.spy(); + let onPageChange beforeEach(function() { + onPageChange = sinon.spy(); wrapper = mount(); }); - afterEach(function() { - onPageChange.reset(); - }); - it('should go to the next page', function() { wrapper.find('#next').simulate('click'); expect(onPageChange.withArgs(6).calledOnce).to.equal(true);