mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 18:48:55 +08:00
tests
This commit is contained in:
@@ -2,7 +2,7 @@ import { expect } from 'chai'
|
||||
import sinon from 'sinon'
|
||||
import { shallowMount } from '@vue/test-utils'
|
||||
import { createStore } from 'vuex'
|
||||
import App from '@/App'
|
||||
import App from '@/App.vue'
|
||||
import storedInquiries from '@/lib/storedInquiries'
|
||||
import mutations from '@/store/mutations'
|
||||
import { nextTick } from 'vue'
|
||||
@@ -59,4 +59,37 @@ describe('App.vue', () => {
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
})
|
||||
|
||||
it('Updates store when inquirires change in local storage', async () => {
|
||||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'baz' },
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
|
||||
const state = {
|
||||
predefinedInquiries: [],
|
||||
inquiries: []
|
||||
}
|
||||
const store = createStore({ state, mutations })
|
||||
shallowMount(App, {
|
||||
global: { stubs: ['router-view'], plugins: [store] }
|
||||
})
|
||||
|
||||
expect(state.inquiries).to.eql([
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 2, name: 'baz' },
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
|
||||
storedInquiries.getStoredInquiries.returns([
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
window.dispatchEvent(new StorageEvent('storage', { key: 'myInquiries' }))
|
||||
expect(state.inquiries).to.eql([
|
||||
{ id: 1, name: 'foo' },
|
||||
{ id: 3, name: 'bar' }
|
||||
])
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user