1
0
mirror of https://github.com/lana-k/sqliteviz.git synced 2025-12-06 18:18:53 +08:00

add test to DbUpload

check that it doesn't redirect to /editor if it's already there
This commit is contained in:
lana-k
2021-03-03 22:33:57 +01:00
parent 6118a12672
commit 854d2adfca

View File

@@ -28,7 +28,7 @@ describe('DbUploader.vue', () => {
// mock router
const $router = { push: sinon.stub() }
const $route = { puth: '/' }
const $route = { path: '/' }
// mount the component
const wrapper = shallowMount(DbUpload, {
@@ -57,7 +57,7 @@ describe('DbUploader.vue', () => {
// mock router
const $router = { push: sinon.stub() }
const $route = { puth: '/' }
const $route = { path: '/' }
// mount the component
const wrapper = shallowMount(DbUpload, {
@@ -79,4 +79,30 @@ describe('DbUploader.vue', () => {
expect(mutations.saveSchema.calledOnceWith(state, schema)).to.equal(true)
expect($router.push.calledOnceWith('/editor')).to.equal(true)
})
it("doesn't redirect if already on /editor", async () => {
// mock store state and mutations
const state = {}
const mutations = {
saveSchema: sinon.stub()
}
const store = new Vuex.Store({ state, mutations })
// mock db loading
const schema = {}
const $db = { loadDb: sinon.stub().resolves(schema) }
// mock router
const $router = { push: sinon.stub() }
const $route = { path: '/' }
// mount the component
const wrapper = shallowMount(DbUpload, {
store,
mocks: { $db, $router, $route }
})
await wrapper.find('.drop-area').trigger('click')
expect($router.push.called).to.equal(false)
})
})