mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 18:48:55 +08:00
add test for setDb store mutation #27
This commit is contained in:
@@ -6,14 +6,26 @@ const {
|
|||||||
deleteTab,
|
deleteTab,
|
||||||
setCurrentTabId,
|
setCurrentTabId,
|
||||||
setCurrentTab,
|
setCurrentTab,
|
||||||
updatePredefinedQueries
|
updatePredefinedQueries,
|
||||||
|
setDb
|
||||||
} = mutations
|
} = mutations
|
||||||
|
|
||||||
const { addTab } = actions
|
const { addTab } = actions
|
||||||
|
|
||||||
describe('mutations', () => {
|
describe('mutations', () => {
|
||||||
|
it('setDb', () => {
|
||||||
|
const state = {
|
||||||
|
db: { shutDown: sinon.spy() }
|
||||||
|
}
|
||||||
|
|
||||||
|
const oldDb = state.db
|
||||||
|
const db = {}
|
||||||
|
setDb(state, db)
|
||||||
|
expect(state.db).to.equal(db)
|
||||||
|
expect(oldDb.shutDown.calledOnce).to.equal(true)
|
||||||
|
})
|
||||||
|
|
||||||
it('saveSchema', () => {
|
it('saveSchema', () => {
|
||||||
// mock state
|
|
||||||
const state = {}
|
const state = {}
|
||||||
|
|
||||||
const schema = [
|
const schema = [
|
||||||
@@ -51,7 +63,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab]
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
@@ -84,7 +95,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab],
|
tabs: [tab],
|
||||||
currentTabId: 1
|
currentTabId: 1
|
||||||
@@ -116,7 +126,6 @@ describe('mutations', () => {
|
|||||||
name: 'new test'
|
name: 'new test'
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab]
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
@@ -145,7 +154,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: true
|
isUnsaved: true
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab]
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
@@ -177,7 +185,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1, tab2],
|
tabs: [tab1, tab2],
|
||||||
currentTabId: 1
|
currentTabId: 1
|
||||||
@@ -208,7 +215,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1, tab2],
|
tabs: [tab1, tab2],
|
||||||
currentTabId: 2
|
currentTabId: 2
|
||||||
@@ -248,7 +254,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1, tab2, tab3],
|
tabs: [tab1, tab2, tab3],
|
||||||
currentTabId: 2
|
currentTabId: 2
|
||||||
@@ -271,7 +276,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1],
|
tabs: [tab1],
|
||||||
currentTabId: 1
|
currentTabId: 1
|
||||||
@@ -301,7 +305,6 @@ describe('mutations', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1, tab2],
|
tabs: [tab1, tab2],
|
||||||
currentTabId: 1
|
currentTabId: 1
|
||||||
@@ -314,7 +317,6 @@ describe('mutations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('setCurrentTabId', () => {
|
it('setCurrentTabId', () => {
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
currentTabId: 1
|
currentTabId: 1
|
||||||
}
|
}
|
||||||
@@ -324,7 +326,6 @@ describe('mutations', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('setCurrentTab', () => {
|
it('setCurrentTab', () => {
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
currentTab: { id: 1 }
|
currentTab: { id: 1 }
|
||||||
}
|
}
|
||||||
@@ -377,7 +378,6 @@ describe('mutations', () => {
|
|||||||
|
|
||||||
describe('actions', () => {
|
describe('actions', () => {
|
||||||
it('addTab adds new blank tab', async () => {
|
it('addTab adds new blank tab', async () => {
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
untitledLastIndex: 0
|
untitledLastIndex: 0
|
||||||
@@ -392,7 +392,6 @@ describe('actions', () => {
|
|||||||
})
|
})
|
||||||
|
|
||||||
it('addTab adds tab from saved queries', async () => {
|
it('addTab adds tab from saved queries', async () => {
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [],
|
tabs: [],
|
||||||
untitledLastIndex: 0
|
untitledLastIndex: 0
|
||||||
@@ -429,7 +428,6 @@ describe('actions', () => {
|
|||||||
isUnsaved: false
|
isUnsaved: false
|
||||||
}
|
}
|
||||||
|
|
||||||
// mock state
|
|
||||||
const state = {
|
const state = {
|
||||||
tabs: [tab1, tab2],
|
tabs: [tab1, tab2],
|
||||||
untitledLastIndex: 0
|
untitledLastIndex: 0
|
||||||
|
|||||||
Reference in New Issue
Block a user