mirror of
https://github.com/lana-k/sqliteviz.git
synced 2025-12-07 02:28:54 +08:00
add test to DbUpload
check that it doesn't redirect to /editor if it's already there
This commit is contained in:
@@ -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)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user