mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-06 18:18:53 +08:00
Compare commits
2 Commits
f55a8caa92
...
3a05b27400
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
3a05b27400 | ||
|
|
108d96a753 |
@@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "sqliteviz",
|
||||
"version": "0.25.0",
|
||||
"version": "0.25.1",
|
||||
"license": "Apache-2.0",
|
||||
"private": true,
|
||||
"scripts": {
|
||||
|
||||
@@ -22,7 +22,7 @@ export default {
|
||||
handler () {
|
||||
storedInquiries.updateStorage(this.inquiries)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
</script>
|
||||
|
||||
@@ -52,19 +52,19 @@ export default {
|
||||
inquiry => !inquiryIdSet.has(inquiry.id)
|
||||
)
|
||||
|
||||
// Close deleted inquiries if it was opened
|
||||
const tabs = state.tabs
|
||||
let i = tabs.length - 1
|
||||
while (i > -1) {
|
||||
if (inquiryIdSet.has(tabs[i].id)) {
|
||||
commit('deleteTab', tabs[i])
|
||||
}
|
||||
i--
|
||||
}
|
||||
// Close deleted inquiries if it was opened
|
||||
const tabs = state.tabs
|
||||
let i = tabs.length - 1
|
||||
while (i > -1) {
|
||||
if (inquiryIdSet.has(tabs[i].id)) {
|
||||
commit('deleteTab', tabs[i])
|
||||
}
|
||||
i--
|
||||
}
|
||||
},
|
||||
renameInquiry ({ state, commit }, {inquiryId, newName}) {
|
||||
renameInquiry ({ state, commit }, { inquiryId, newName }) {
|
||||
const renamingInquiry = state.inquiries
|
||||
.find(inquiry => inquiry.id === inquiryId)
|
||||
.find(inquiry => inquiry.id === inquiryId)
|
||||
|
||||
renamingInquiry.name = newName
|
||||
|
||||
|
||||
@@ -332,7 +332,7 @@ export default {
|
||||
return
|
||||
}
|
||||
this.$store.dispatch('renameInquiry', {
|
||||
inquiryId: this.processedInquiryId,
|
||||
inquiryId: this.processedInquiryId,
|
||||
newName: this.newName
|
||||
})
|
||||
|
||||
|
||||
@@ -133,8 +133,8 @@ export default {
|
||||
|
||||
// Save inquiry
|
||||
const value = await this.$store.dispatch('saveInquiry', {
|
||||
inquiryTab:this.currentInquiry,
|
||||
newName:this.name
|
||||
inquiryTab: this.currentInquiry,
|
||||
newName: this.name
|
||||
})
|
||||
|
||||
// Update tab in store
|
||||
|
||||
@@ -13,7 +13,7 @@ describe('App.vue', () => {
|
||||
|
||||
it('Gets inquiries', () => {
|
||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||
{id: 1}, {id: 2}, {id: 3}
|
||||
{ id: 1 }, { id: 2 }, { id: 3 }
|
||||
])
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
@@ -22,16 +22,15 @@ describe('App.vue', () => {
|
||||
const store = new Vuex.Store({ state, mutations })
|
||||
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 () => {
|
||||
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')
|
||||
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: []
|
||||
@@ -39,13 +38,15 @@ describe('App.vue', () => {
|
||||
const store = new Vuex.Store({ state, mutations })
|
||||
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()
|
||||
|
||||
expect(storedInquiries.updateStorage.calledTwice).to.equal(true)
|
||||
|
||||
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,8 +1,9 @@
|
||||
import { expect } from 'chai'
|
||||
import actions from '@/store/actions'
|
||||
import sinon from 'sinon'
|
||||
|
||||
const {
|
||||
addTab,
|
||||
const {
|
||||
addTab,
|
||||
addInquiry,
|
||||
deleteInquiries,
|
||||
renameInquiry,
|
||||
@@ -90,11 +91,11 @@ describe('actions', () => {
|
||||
|
||||
it('addInquiry', async () => {
|
||||
const state = {
|
||||
inquiries: [1,2,3]
|
||||
inquiries: [1, 2, 3]
|
||||
}
|
||||
|
||||
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 () => {
|
||||
@@ -112,19 +113,19 @@ describe('actions', () => {
|
||||
it('renameInquiry', async () => {
|
||||
const state = {
|
||||
inquiries: [
|
||||
{ id: 1, name: 'foo'},
|
||||
{ id: 2, name: 'bar' },
|
||||
{ id: 3, name: 'baz' },
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'bar' },
|
||||
{ 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()
|
||||
|
||||
await renameInquiry({ state, commit }, {inquiryId: 2, newName: 'new name'})
|
||||
await renameInquiry({ state, commit }, { inquiryId: 2, newName: 'new name' })
|
||||
expect(state.inquiries).to.eql([
|
||||
{ id: 1, name: 'foo'},
|
||||
{ id: 2, name: 'new name' },
|
||||
{ id: 3, name: 'baz' },
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'new name' },
|
||||
{ id: 3, name: 'baz' }
|
||||
])
|
||||
expect(commit.calledWith('updateTab', {
|
||||
tab: { id: 2, name: 'bar' },
|
||||
@@ -137,7 +138,7 @@ describe('actions', () => {
|
||||
it('saveInquiry adds new inquiry in the storage', async () => {
|
||||
const now = new Date()
|
||||
const nowPlusMinute = new Date(now.getTime() + 60 * 1000)
|
||||
|
||||
|
||||
const tab = {
|
||||
id: 1,
|
||||
query: 'select * from foo',
|
||||
@@ -152,12 +153,12 @@ describe('actions', () => {
|
||||
}
|
||||
const state = {
|
||||
inquiries: [],
|
||||
tabs: [tab],
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
const value = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
const value = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
expect(value.id).to.equal(tab.id)
|
||||
expect(value.name).to.equal('foo')
|
||||
@@ -183,12 +184,12 @@ describe('actions', () => {
|
||||
|
||||
const state = {
|
||||
inquiries: [],
|
||||
tabs: [tab],
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
const first = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
const first = await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
|
||||
tab.name = 'foo'
|
||||
@@ -223,12 +224,12 @@ describe('actions', () => {
|
||||
|
||||
const state = {
|
||||
inquiries: [],
|
||||
tabs: [tab],
|
||||
tabs: [tab]
|
||||
}
|
||||
|
||||
await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
await saveInquiry({ state }, {
|
||||
inquiryTab: tab,
|
||||
newName: 'foo'
|
||||
})
|
||||
|
||||
const inquiries = state.inquiries
|
||||
|
||||
@@ -367,7 +367,7 @@ describe('mutations', () => {
|
||||
inquiries: []
|
||||
}
|
||||
|
||||
setInquiries(state, [1,2,3])
|
||||
expect(state.inquiries).to.eql([1,2,3])
|
||||
setInquiries(state, [1, 2, 3])
|
||||
expect(state.inquiries).to.eql([1, 2, 3])
|
||||
})
|
||||
})
|
||||
|
||||
@@ -95,7 +95,7 @@ describe('Inquiries.vue', () => {
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [
|
||||
@@ -140,7 +140,7 @@ describe('Inquiries.vue', () => {
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [
|
||||
@@ -184,7 +184,7 @@ describe('Inquiries.vue', () => {
|
||||
createdAt: '2020-03-08T19:57:56.299Z'
|
||||
}
|
||||
])
|
||||
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [
|
||||
@@ -775,7 +775,7 @@ describe('Inquiries.vue', () => {
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: [inquiryInStore]
|
||||
inquiries: [inquiryInStore]
|
||||
}
|
||||
const store = new Vuex.Store({ state, mutations, actions })
|
||||
|
||||
|
||||
@@ -361,7 +361,6 @@ describe('MainMenu.vue', () => {
|
||||
const store = new Vuex.Store({ state, mutations, actions })
|
||||
const $route = { path: '/workspace' }
|
||||
sinon.stub(storedInquiries, 'isTabNeedName').returns(false)
|
||||
|
||||
|
||||
wrapper = mount(MainMenu, {
|
||||
store,
|
||||
@@ -376,8 +375,8 @@ describe('MainMenu.vue', () => {
|
||||
|
||||
// check that the inquiry was saved via saveInquiry (newName='')
|
||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab:state.currentTab, newName: ''
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab: state.currentTab, newName: ''
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
@@ -499,7 +498,7 @@ describe('MainMenu.vue', () => {
|
||||
.find(button => button.text() === 'Save')
|
||||
.trigger('click')
|
||||
|
||||
await wrapper.vm.$nextTick()
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
// check that the dialog is closed
|
||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||
@@ -507,8 +506,8 @@ describe('MainMenu.vue', () => {
|
||||
// check that the inquiry was saved via saveInquiry (newName='foo')
|
||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab:state.currentTab,
|
||||
newName:'foo'
|
||||
inquiryTab: state.currentTab,
|
||||
newName: 'foo'
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
@@ -590,16 +589,16 @@ describe('MainMenu.vue', () => {
|
||||
.find(button => button.text() === 'Save')
|
||||
.trigger('click')
|
||||
|
||||
await wrapper.vm.$nextTick()
|
||||
await wrapper.vm.$nextTick()
|
||||
|
||||
// check that the dialog is closed
|
||||
expect(wrapper.find('[data-modal="save"]').exists()).to.equal(false)
|
||||
|
||||
// check that the inquiry was saved via saveInquiry (newName='bar')
|
||||
expect(actions.saveInquiry.calledOnce).to.equal(true)
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab:state.currentTab,
|
||||
newName: 'bar'
|
||||
expect(actions.saveInquiry.args[0][1]).to.eql({
|
||||
inquiryTab: state.currentTab,
|
||||
newName: 'bar'
|
||||
})
|
||||
|
||||
// check that the tab was updated
|
||||
|
||||
Reference in New Issue
Block a user