1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

restore sinon in afterEach hook

This commit is contained in:
lana-k
2021-04-11 21:52:09 +02:00
parent 73c0936927
commit 1945467dc7
2 changed files with 8 additions and 16 deletions

View File

@@ -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()
})
})

View File

@@ -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', () => {