mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
restore sinon
This commit is contained in:
@@ -4,6 +4,10 @@ import * as chart from '@/chart'
|
|||||||
import * as dereference from 'react-chart-editor/lib/lib/dereference'
|
import * as dereference from 'react-chart-editor/lib/lib/dereference'
|
||||||
|
|
||||||
describe('chart.js', () => {
|
describe('chart.js', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
|
|
||||||
it('getDataSourcesFromSqlResult', () => {
|
it('getDataSourcesFromSqlResult', () => {
|
||||||
const sqlResult = {
|
const sqlResult = {
|
||||||
columns: ['id', 'name'],
|
columns: ['id', 'name'],
|
||||||
@@ -47,11 +51,12 @@ describe('chart.js', () => {
|
|||||||
name: ['foo', 'bar']
|
name: ['foo', 'bar']
|
||||||
}
|
}
|
||||||
sinon.stub(dereference, 'default')
|
sinon.stub(dereference, 'default')
|
||||||
|
sinon.spy(JSON, 'parse')
|
||||||
|
|
||||||
const ds = chart.getChartStateForSave(state, dataSources)
|
const ds = chart.getChartStateForSave(state, dataSources)
|
||||||
|
|
||||||
expect(dereference.default.calledOnce).to.equal(true)
|
expect(dereference.default.calledOnce).to.equal(true)
|
||||||
|
|
||||||
const args = dereference.default.firstCall.args
|
const args = dereference.default.firstCall.args
|
||||||
expect(args[0]).to.eql({
|
expect(args[0]).to.eql({
|
||||||
foo: {},
|
foo: {},
|
||||||
@@ -61,5 +66,7 @@ describe('chart.js', () => {
|
|||||||
id: [],
|
id: [],
|
||||||
name: []
|
name: []
|
||||||
})
|
})
|
||||||
|
|
||||||
|
expect(ds).to.equal(JSON.parse.returnValues[0])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
Reference in New Issue
Block a user