mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
fix errors in tests
This commit is contained in:
@@ -2,6 +2,8 @@ import { expect } from 'chai'
|
|||||||
import sinon from 'sinon'
|
import sinon from 'sinon'
|
||||||
import { mount, createLocalVue } from '@vue/test-utils'
|
import { mount, createLocalVue } from '@vue/test-utils'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
|
import actions from '@/store/actions'
|
||||||
|
import mutations from '@/store/mutations'
|
||||||
import Schema from '@/views/Main/Workspace/Schema'
|
import Schema from '@/views/Main/Workspace/Schema'
|
||||||
import TableDescription from '@/views/Main/Workspace/Schema/TableDescription'
|
import TableDescription from '@/views/Main/Workspace/Schema/TableDescription'
|
||||||
import database from '@/lib/database'
|
import database from '@/lib/database'
|
||||||
@@ -140,14 +142,15 @@ describe('Schema.vue', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
db: database.getNewDatabase()
|
db: database.getNewDatabase(),
|
||||||
|
tabs: []
|
||||||
}
|
}
|
||||||
state.db.dbName = 'db'
|
state.db.dbName = 'db'
|
||||||
state.db.execute('CREATE TABLE foo(id)')
|
state.db.execute('CREATE TABLE foo(id)')
|
||||||
state.db.refreshSchema()
|
state.db.refreshSchema()
|
||||||
sinon.spy(state.db, 'refreshSchema')
|
sinon.spy(state.db, 'refreshSchema')
|
||||||
|
|
||||||
const store = new Vuex.Store({ state })
|
const store = new Vuex.Store({ state, actions, mutations })
|
||||||
const wrapper = mount(Schema, { store, localVue })
|
const wrapper = mount(Schema, { store, localVue })
|
||||||
sinon.spy(wrapper.vm.$refs.addCsv, 'previewCsv')
|
sinon.spy(wrapper.vm.$refs.addCsv, 'previewCsv')
|
||||||
sinon.spy(wrapper.vm, 'addCsv')
|
sinon.spy(wrapper.vm, 'addCsv')
|
||||||
|
|||||||
@@ -2,8 +2,12 @@ import { expect } from 'chai'
|
|||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import Pivot from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot'
|
import Pivot from '@/views/Main/Workspace/Tabs/Tab/DataView/Pivot'
|
||||||
import $ from 'jquery'
|
import $ from 'jquery'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
describe('Pivot.vue', () => {
|
describe('Pivot.vue', () => {
|
||||||
|
afterEach(() => {
|
||||||
|
sinon.restore()
|
||||||
|
})
|
||||||
it('renders pivot table', () => {
|
it('renders pivot table', () => {
|
||||||
const wrapper = mount(Pivot, {
|
const wrapper = mount(Pivot, {
|
||||||
propsData: {
|
propsData: {
|
||||||
@@ -191,6 +195,7 @@ describe('Pivot.vue', () => {
|
|||||||
rendererName: 'Custom chart',
|
rendererName: 'Custom chart',
|
||||||
rendererOptions: {
|
rendererOptions: {
|
||||||
customChartComponent: {
|
customChartComponent: {
|
||||||
|
$mount: sinon.stub(),
|
||||||
getOptionsForSave () {
|
getOptionsForSave () {
|
||||||
return { here_are: 'custom chart settings' }
|
return { here_are: 'custom chart settings' }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -231,8 +231,11 @@ describe('Tab.vue', () => {
|
|||||||
|
|
||||||
it('Passes result to sql-table component', async () => {
|
it('Passes result to sql-table component', async () => {
|
||||||
const result = {
|
const result = {
|
||||||
id: [1, 2],
|
columns: ['id', 'name'],
|
||||||
name: ['foo', 'bar']
|
values: {
|
||||||
|
id: [1, 2],
|
||||||
|
name: ['foo', 'bar']
|
||||||
|
}
|
||||||
}
|
}
|
||||||
// mock store state
|
// mock store state
|
||||||
const state = {
|
const state = {
|
||||||
@@ -269,8 +272,11 @@ describe('Tab.vue', () => {
|
|||||||
|
|
||||||
it('Updates schema after query execution', async () => {
|
it('Updates schema after query execution', async () => {
|
||||||
const result = {
|
const result = {
|
||||||
id: [],
|
columns: ['id', 'name'],
|
||||||
name: []
|
values: {
|
||||||
|
id: [],
|
||||||
|
name: []
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock store state
|
// mock store state
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import { mount } from '@vue/test-utils'
|
import { mount } from '@vue/test-utils'
|
||||||
import actions from '@/store/actions'
|
import actions from '@/store/actions'
|
||||||
|
import mutations from '@/store/mutations'
|
||||||
import Vuex from 'vuex'
|
import Vuex from 'vuex'
|
||||||
import Workspace from '@/views/Main/Workspace'
|
import Workspace from '@/views/Main/Workspace'
|
||||||
|
|
||||||
@@ -10,8 +11,11 @@ describe('Workspace.vue', () => {
|
|||||||
db: {},
|
db: {},
|
||||||
tabs: []
|
tabs: []
|
||||||
}
|
}
|
||||||
const store = new Vuex.Store({ state, actions })
|
const store = new Vuex.Store({ state, actions, mutations })
|
||||||
mount(Workspace, { store })
|
mount(Workspace, {
|
||||||
|
store,
|
||||||
|
stubs: ['router-link']
|
||||||
|
})
|
||||||
|
|
||||||
expect(state.tabs[0].query).to.include('Your database is empty.')
|
expect(state.tabs[0].query).to.include('Your database is empty.')
|
||||||
expect(state.tabs[0].tempName).to.equal('Untitled')
|
expect(state.tabs[0].tempName).to.equal('Untitled')
|
||||||
Reference in New Issue
Block a user