Skip to content

Instantly share code, notes, and snippets.

@matthewblewitt
Last active August 20, 2019 10:15
Show Gist options
  • Save matthewblewitt/5098b93caea8c2a5b5771c34cc4b7051 to your computer and use it in GitHub Desktop.
Save matthewblewitt/5098b93caea8c2a5b5771c34cc4b7051 to your computer and use it in GitHub Desktop.
Vue util cheat sheet
import { mount, createLocalVue } from "vue-test-utils";
import { actions, mutations } from "~/test/mocks/store-actions-mutations.mock";
import Component from "~/pages/index.vue";
import Vuex from "vuex";
const localVue = createLocalVue();
localVue.use(Vuex);
const store = new Vuex.Store({ state, mutations, actions });
const cmp = mount(Component, {
store,
localVue,
stubs: {
ChildComponent: "<div></div>"
},
mocks: {
$router: {
push: jest.fn()
}
}
});
cmp.setData({pageSize: count})
describe("watch", () => {
it("pageIsValid should fire set progress navigation", next => {
cmp.setComputed({
pageIsValid: true
});
cmp.vm.$nextTick(() => {
expect(mutations.SET_PROGRESS_NAVIGATION.mock.calls[0][1]).toEqual({
valid: true
});
next();
});
});
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment