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:
@@ -5,6 +5,10 @@ import hint, { getHints } from '@/hint'
|
|||||||
import CM from 'codemirror'
|
import CM from 'codemirror'
|
||||||
|
|
||||||
describe('hint.js', () => {
|
describe('hint.js', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
it('Calculates table list for hint', () => {
|
it('Calculates table list for hint', () => {
|
||||||
// mock store state
|
// mock store state
|
||||||
const schema = [
|
const schema = [
|
||||||
@@ -45,8 +49,6 @@ describe('hint.js', () => {
|
|||||||
foo: ['fooId', 'name'],
|
foo: ['fooId', 'name'],
|
||||||
bar: ['barId']
|
bar: ['barId']
|
||||||
})
|
})
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't show hint when in string or space, or ';'", () => {
|
it("Doesn't show hint when in string or space, or ';'", () => {
|
||||||
@@ -67,8 +69,6 @@ describe('hint.js', () => {
|
|||||||
clock.tick(500)
|
clock.tick(500)
|
||||||
|
|
||||||
expect(CM.showHint.called).to.equal(false)
|
expect(CM.showHint.called).to.equal(false)
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't show hint after space", () => {
|
it("Doesn't show hint after space", () => {
|
||||||
@@ -89,8 +89,6 @@ describe('hint.js', () => {
|
|||||||
clock.tick(500)
|
clock.tick(500)
|
||||||
|
|
||||||
expect(CM.showHint.called).to.equal(false)
|
expect(CM.showHint.called).to.equal(false)
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it("Doesn't show hint after ';'", () => {
|
it("Doesn't show hint after ';'", () => {
|
||||||
@@ -111,8 +109,6 @@ describe('hint.js', () => {
|
|||||||
clock.tick(500)
|
clock.tick(500)
|
||||||
|
|
||||||
expect(CM.showHint.called).to.equal(false)
|
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', () => {
|
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, {})
|
const hints = getHints(editor, {})
|
||||||
expect(hints.list).to.eql([])
|
expect(hints.list).to.eql([])
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('getHints returns hints as is when there are more than one option', () => {
|
it('getHints returns hints as is when there are more than one option', () => {
|
||||||
@@ -173,8 +167,6 @@ describe('hint.js', () => {
|
|||||||
|
|
||||||
const hints = getHints(editor, {})
|
const hints = getHints(editor, {})
|
||||||
expect(hints.list).to.eql(list)
|
expect(hints.list).to.eql(list)
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('tables is empty object when schema is null', () => {
|
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.called).to.equal(true)
|
||||||
expect(CM.showHint.firstCall.args[2].tables).to.eql({})
|
expect(CM.showHint.firstCall.args[2].tables).to.eql({})
|
||||||
|
|
||||||
sinon.restore()
|
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ describe('storedQueries.js', () => {
|
|||||||
localStorage.removeItem('myQueries')
|
localStorage.removeItem('myQueries')
|
||||||
})
|
})
|
||||||
|
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
it('getStoredQueries returns emplty array when storage is empty', () => {
|
it('getStoredQueries returns emplty array when storage is empty', () => {
|
||||||
const queries = storedQueries.getStoredQueries()
|
const queries = storedQueries.getStoredQueries()
|
||||||
expect(queries).to.eql([])
|
expect(queries).to.eql([])
|
||||||
@@ -157,7 +161,6 @@ describe('storedQueries.js', () => {
|
|||||||
`
|
`
|
||||||
sinon.stub(fu, 'importFile').returns(Promise.resolve(str))
|
sinon.stub(fu, 'importFile').returns(Promise.resolve(str))
|
||||||
const queries = await storedQueries.importQueries()
|
const queries = await storedQueries.importQueries()
|
||||||
fu.importFile.restore()
|
|
||||||
|
|
||||||
expect(queries).to.eql([JSON.parse(str)])
|
expect(queries).to.eql([JSON.parse(str)])
|
||||||
})
|
})
|
||||||
@@ -176,7 +179,6 @@ describe('storedQueries.js', () => {
|
|||||||
const queries = await storedQueries.readPredefinedQueries()
|
const queries = await storedQueries.readPredefinedQueries()
|
||||||
expect(fu.readFile.calledOnceWith('./queries.json')).to.equal(true)
|
expect(fu.readFile.calledOnceWith('./queries.json')).to.equal(true)
|
||||||
expect(queries).to.eql(JSON.parse(str))
|
expect(queries).to.eql(JSON.parse(str))
|
||||||
fu.readFile.restore()
|
|
||||||
})
|
})
|
||||||
|
|
||||||
it('save adds new query in the storage', () => {
|
it('save adds new query in the storage', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user