From 1945467dc732b522eedd348184933b8f494ebe72 Mon Sep 17 00:00:00 2001 From: lana-k Date: Sun, 11 Apr 2021 21:52:09 +0200 Subject: [PATCH] restore sinon in afterEach hook --- tests/unit/hint.spec.js | 18 ++++-------------- tests/unit/storedQueries.spec.js | 6 ++++-- 2 files changed, 8 insertions(+), 16 deletions(-) diff --git a/tests/unit/hint.spec.js b/tests/unit/hint.spec.js index 25326aa..c059599 100644 --- a/tests/unit/hint.spec.js +++ b/tests/unit/hint.spec.js @@ -5,6 +5,10 @@ import hint, { getHints } from '@/hint' import CM from 'codemirror' describe('hint.js', () => { + afterEach(() => { + sinon.restore() + }) + it('Calculates table list for hint', () => { // mock store state const schema = [ @@ -45,8 +49,6 @@ describe('hint.js', () => { foo: ['fooId', 'name'], bar: ['barId'] }) - - sinon.restore() }) it("Doesn't show hint when in string or space, or ';'", () => { @@ -67,8 +69,6 @@ describe('hint.js', () => { clock.tick(500) expect(CM.showHint.called).to.equal(false) - - sinon.restore() }) it("Doesn't show hint after space", () => { @@ -89,8 +89,6 @@ describe('hint.js', () => { clock.tick(500) expect(CM.showHint.called).to.equal(false) - - sinon.restore() }) it("Doesn't show hint after ';'", () => { @@ -111,8 +109,6 @@ describe('hint.js', () => { clock.tick(500) expect(CM.showHint.called).to.equal(false) - - sinon.restore() }) it('getHints returns [ ] if there is only one option and the token is already completed with this option', () => { @@ -130,8 +126,6 @@ describe('hint.js', () => { const hints = getHints(editor, {}) expect(hints.list).to.eql([]) - - sinon.restore() }) it('getHints returns hints as is when there are more than one option', () => { @@ -173,8 +167,6 @@ describe('hint.js', () => { const hints = getHints(editor, {}) expect(hints.list).to.eql(list) - - sinon.restore() }) it('tables is empty object when schema is null', () => { @@ -199,7 +191,5 @@ describe('hint.js', () => { expect(CM.showHint.called).to.equal(true) expect(CM.showHint.firstCall.args[2].tables).to.eql({}) - - sinon.restore() }) }) diff --git a/tests/unit/storedQueries.spec.js b/tests/unit/storedQueries.spec.js index c76351e..d5595ce 100644 --- a/tests/unit/storedQueries.spec.js +++ b/tests/unit/storedQueries.spec.js @@ -8,6 +8,10 @@ describe('storedQueries.js', () => { localStorage.removeItem('myQueries') }) + afterEach(() => { + sinon.restore() + }) + it('getStoredQueries returns emplty array when storage is empty', () => { const queries = storedQueries.getStoredQueries() expect(queries).to.eql([]) @@ -157,7 +161,6 @@ describe('storedQueries.js', () => { ` sinon.stub(fu, 'importFile').returns(Promise.resolve(str)) const queries = await storedQueries.importQueries() - fu.importFile.restore() expect(queries).to.eql([JSON.parse(str)]) }) @@ -176,7 +179,6 @@ describe('storedQueries.js', () => { const queries = await storedQueries.readPredefinedQueries() expect(fu.readFile.calledOnceWith('./queries.json')).to.equal(true) expect(queries).to.eql(JSON.parse(str)) - fu.readFile.restore() }) it('save adds new query in the storage', () => {