mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
#121 fix lint
This commit is contained in:
@@ -52,19 +52,19 @@ export default {
|
|||||||
inquiry => !inquiryIdSet.has(inquiry.id)
|
inquiry => !inquiryIdSet.has(inquiry.id)
|
||||||
)
|
)
|
||||||
|
|
||||||
// Close deleted inquiries if it was opened
|
// Close deleted inquiries if it was opened
|
||||||
const tabs = state.tabs
|
const tabs = state.tabs
|
||||||
let i = tabs.length - 1
|
let i = tabs.length - 1
|
||||||
while (i > -1) {
|
while (i > -1) {
|
||||||
if (inquiryIdSet.has(tabs[i].id)) {
|
if (inquiryIdSet.has(tabs[i].id)) {
|
||||||
commit('deleteTab', tabs[i])
|
commit('deleteTab', tabs[i])
|
||||||
}
|
}
|
||||||
i--
|
i--
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
renameInquiry ({ state, commit }, {inquiryId, newName}) {
|
renameInquiry ({ state, commit }, { inquiryId, newName }) {
|
||||||
const renamingInquiry = state.inquiries
|
const renamingInquiry = state.inquiries
|
||||||
.find(inquiry => inquiry.id === inquiryId)
|
.find(inquiry => inquiry.id === inquiryId)
|
||||||
|
|
||||||
renamingInquiry.name = newName
|
renamingInquiry.name = newName
|
||||||
|
|
||||||
|
|||||||
@@ -133,8 +133,8 @@ export default {
|
|||||||
|
|
||||||
// Save inquiry
|
// Save inquiry
|
||||||
const value = await this.$store.dispatch('saveInquiry', {
|
const value = await this.$store.dispatch('saveInquiry', {
|
||||||
inquiryTab:this.currentInquiry,
|
inquiryTab: this.currentInquiry,
|
||||||
newName:this.name
|
newName: this.name
|
||||||
})
|
})
|
||||||
|
|
||||||
// Update tab in store
|
// Update tab in store
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ describe('App.vue', () => {
|
|||||||
|
|
||||||
it('Gets inquiries', () => {
|
it('Gets inquiries', () => {
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||||
{id: 1}, {id: 2}, {id: 3}
|
{ id: 1 }, { id: 2 }, { id: 3 }
|
||||||
])
|
])
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: [],
|
predefinedInquiries: [],
|
||||||
@@ -22,16 +22,15 @@ describe('App.vue', () => {
|
|||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations })
|
||||||
shallowMount(App, { store, stubs: ['router-view'] })
|
shallowMount(App, { store, stubs: ['router-view'] })
|
||||||
|
|
||||||
expect(state.inquiries).to.eql([{id: 1}, {id: 2}, {id: 3}])
|
expect(state.inquiries).to.eql([{ id: 1 }, { id: 2 }, { id: 3 }])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('Updates inquiries when they change in store', async () => {
|
it('Updates inquiries when they change in store', async () => {
|
||||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||||
{id: 1, name: 'foo'}, {id: 2, name: 'baz'}, {id: 3, name: 'bar'}
|
{ id: 1, name: 'foo' }, { id: 2, name: 'baz' }, { id: 3, name: 'bar' }
|
||||||
])
|
])
|
||||||
sinon.spy(storedInquiries, 'updateStorage')
|
sinon.spy(storedInquiries, 'updateStorage')
|
||||||
|
|
||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
predefinedInquiries: [],
|
predefinedInquiries: [],
|
||||||
inquiries: []
|
inquiries: []
|
||||||
@@ -39,13 +38,15 @@ describe('App.vue', () => {
|
|||||||
const store = new Vuex.Store({ state, mutations })
|
const store = new Vuex.Store({ state, mutations })
|
||||||
const wrapper = shallowMount(App, { store, stubs: ['router-view'] })
|
const wrapper = shallowMount(App, { store, stubs: ['router-view'] })
|
||||||
|
|
||||||
store.state.inquiries.splice(0, 1, {id: 1, name: 'new foo name'})
|
store.state.inquiries.splice(0, 1, { id: 1, name: 'new foo name' })
|
||||||
await wrapper.vm.$nextTick()
|
await wrapper.vm.$nextTick()
|
||||||
|
|
||||||
expect(storedInquiries.updateStorage.calledTwice).to.equal(true)
|
expect(storedInquiries.updateStorage.calledTwice).to.equal(true)
|
||||||
|
|
||||||
expect(storedInquiries.updateStorage.args[1][0]).to.eql([
|
expect(storedInquiries.updateStorage.args[1][0]).to.eql([
|
||||||
{id: 1, name: 'new foo name'}, {id: 2, name: 'baz'}, {id: 3, name: 'bar'}
|
{ id: 1, name: 'new foo name' },
|
||||||
|
{ id: 2, name: 'baz' },
|
||||||
|
{ id: 3, name: 'bar' }
|
||||||
])
|
])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,5 +1,6 @@
|
|||||||
import { expect } from 'chai'
|
import { expect } from 'chai'
|
||||||
import actions from '@/store/actions'
|
import actions from '@/store/actions'
|
||||||
|
import sinon from 'sinon'
|
||||||
|
|
||||||
const {
|
const {
|
||||||
addTab,
|
addTab,
|
||||||
@@ -90,11 +91,11 @@ describe('actions', () => {
|
|||||||
|
|
||||||
it('addInquiry', async () => {
|
it('addInquiry', async () => {
|
||||||
const state = {
|
const state = {
|
||||||
inquiries: [1,2,3]
|
inquiries: [1, 2, 3]
|
||||||
}
|
}
|
||||||
|
|
||||||
await addInquiry({ state }, 4)
|
await addInquiry({ state }, 4)
|
||||||
expect(state.inquiries).to.eql([1,2,3,4])
|
expect(state.inquiries).to.eql([1, 2, 3, 4])
|
||||||
})
|
})
|
||||||
|
|
||||||
it('deleteInquiries', async () => {
|
it('deleteInquiries', async () => {
|
||||||
@@ -112,19 +113,19 @@ describe('actions', () => {
|
|||||||
it('renameInquiry', async () => {
|
it('renameInquiry', async () => {
|
||||||
const state = {
|
const state = {
|
||||||
inquiries: [
|
inquiries: [
|
||||||
{ id: 1, name: 'foo'},
|
{ id: 1, name: 'foo' },
|
||||||
{ id: 2, name: 'bar' },
|
{ id: 2, name: 'bar' },
|
||||||
{ id: 3, name: 'baz' },
|
{ id: 3, name: 'baz' }
|
||||||
],
|
],
|
||||||
tabs: [{ id: 1, name: 'foo'}, { id: 2, name: 'bar' }]
|
tabs: [{ id: 1, name: 'foo' }, { id: 2, name: 'bar' }]
|
||||||
}
|
}
|
||||||
const commit = sinon.spy()
|
const commit = sinon.spy()
|
||||||
|
|
||||||
await renameInquiry({ state, commit }, {inquiryId: 2, newName: 'new name'})
|
await renameInquiry({ state, commit }, { inquiryId: 2, newName: 'new name' })
|
||||||
expect(state.inquiries).to.eql([
|
expect(state.inquiries).to.eql([
|
||||||
{ id: 1, name: 'foo'},
|
{ id: 1, name: 'foo' },
|
||||||
{ id: 2, name: 'new name' },
|
{ id: 2, name: 'new name' },
|
||||||
{ id: 3, name: 'baz' },
|
{ id: 3, name: 'baz' }
|
||||||
])
|
])
|
||||||
expect(commit.calledWith('updateTab', {
|
expect(commit.calledWith('updateTab', {
|
||||||
tab: { id: 2, name: 'bar' },
|
tab: { id: 2, name: 'bar' },
|
||||||
@@ -152,7 +153,7 @@ describe('actions', () => {
|
|||||||
}
|
}
|
||||||
const state = {
|
const state = {
|
||||||
inquiries: [],
|
inquiries: [],
|
||||||
tabs: [tab],
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
|
|
||||||
const value = await saveInquiry({ state }, {
|
const value = await saveInquiry({ state }, {
|
||||||
@@ -183,7 +184,7 @@ describe('actions', () => {
|
|||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
inquiries: [],
|
inquiries: [],
|
||||||
tabs: [tab],
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
|
|
||||||
const first = await saveInquiry({ state }, {
|
const first = await saveInquiry({ state }, {
|
||||||
@@ -223,7 +224,7 @@ describe('actions', () => {
|
|||||||
|
|
||||||
const state = {
|
const state = {
|
||||||
inquiries: [],
|
inquiries: [],
|
||||||
tabs: [tab],
|
tabs: [tab]
|
||||||
}
|
}
|
||||||
|
|
||||||
await saveInquiry({ state }, {
|
await saveInquiry({ state }, {
|
||||||
|
|||||||
@@ -367,7 +367,7 @@ describe('mutations', () => {
|
|||||||
inquiries: []
|
inquiries: []
|
||||||
}
|
}
|
||||||
|
|
||||||
setInquiries(state, [1,2,3])
|
setInquiries(state, [1, 2, 3])
|
||||||
expect(state.inquiries).to.eql([1,2,3])
|
expect(state.inquiries).to.eql([1, 2, 3])
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -362,7 +362,6 @@ describe('MainMenu.vue', () => {
|
|||||||
const $route = { path: '/workspace' }
|
const $route = { path: '/workspace' }
|
||||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
||||||
|
|
||||||
|
|
||||||
wrapper = mount(MainMenu, {
|
wrapper = mount(MainMenu, {
|
||||||
store,
|
store,
|
||||||
mocks: { $route },
|
mocks: { $route },
|
||||||
@@ -377,7 +376,7 @@ describe('MainMenu.vue', () => {
|
|||||||
// check that the inquiry was saved via saveInquiry (newName='')
|
// check that the inquiry was saved via saveInquiry (newName='')
|
||||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
inquiryTab:state.currentTab, newName: ''
|
inquiryTab: state.currentTab, newName: ''
|
||||||
})
|
})
|
||||||
|
|
||||||
// check that the tab was updated
|
// check that the tab was updated
|
||||||
@@ -507,8 +506,8 @@ describe('MainMenu.vue', () => {
|
|||||||
// check that the inquiry was saved via saveInquiry (newName='foo')
|
// check that the inquiry was saved via saveInquiry (newName='foo')
|
||||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
inquiryTab:state.currentTab,
|
inquiryTab: state.currentTab,
|
||||||
newName:'foo'
|
newName: 'foo'
|
||||||
})
|
})
|
||||||
|
|
||||||
// check that the tab was updated
|
// check that the tab was updated
|
||||||
@@ -598,7 +597,7 @@ describe('MainMenu.vue', () => {
|
|||||||
// check that the inquiry was saved via saveInquiry (newName='bar')
|
// check that the inquiry was saved via saveInquiry (newName='bar')
|
||||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||||
inquiryTab:state.currentTab,
|
inquiryTab: state.currentTab,
|
||||||
newName: 'bar'
|
newName: 'bar'
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user