-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
421 additions
and
339 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import { expect } from 'chai' | ||
import sinon from 'sinon' | ||
import { shallowMount } from '@vue/test-utils' | ||
import Vuex from 'vuex' | ||
import App from '@/App' | ||
import storedInquiries from '@/lib/storedInquiries' | ||
import mutations from '@/store/mutations' | ||
|
||
describe('App.vue', () => { | ||
afterEach(() => { | ||
sinon.restore() | ||
}) | ||
|
||
it('Gets inquiries', () => { | ||
sinon.stub(storedInquiries, 'getStoredInquiries').returns([ | ||
{id: 1}, {id: 2}, {id: 3} | ||
]) | ||
const state = { | ||
predefinedInquiries: [], | ||
inquiries: [] | ||
} | ||
const store = new Vuex.Store({ state, mutations }) | ||
shallowMount(App, { store, stubs: ['router-view'] }) | ||
|
||
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'} | ||
]) | ||
sinon.spy(storedInquiries, 'updateStorage') | ||
|
||
|
||
const state = { | ||
predefinedInquiries: [], | ||
inquiries: [] | ||
} | ||
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'}) | ||
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'} | ||
]) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.