57 lines
1.3 KiB
JavaScript
57 lines
1.3 KiB
JavaScript
import { mount, createLocalVue } from "@vue/test-utils";
|
|
import Vuex from "vuex";
|
|
import Location from "./_id";
|
|
|
|
let $route = {
|
|
path: "/locations",
|
|
params: {
|
|
id: "2baf70d1-42bb-4437-b551-e5fed5a87abe"
|
|
}
|
|
};
|
|
|
|
const localVue = createLocalVue();
|
|
localVue.use(Vuex);
|
|
|
|
describe("Location page", () => {
|
|
let state, actions, store;
|
|
|
|
beforeEach(() => {
|
|
state = {
|
|
location: {}
|
|
};
|
|
actions = {
|
|
getLocation: jest.fn()
|
|
};
|
|
store = new Vuex.Store({ state, actions });
|
|
});
|
|
|
|
it("should render Location page instance", () => {
|
|
const wrapper = mount(Location, { localVue, store });
|
|
expect(wrapper.exists()).toBe(true);
|
|
});
|
|
|
|
it("tests params validation", () => {
|
|
expect(Location.validate({ params: $route.params })).toBe(true);
|
|
expect(
|
|
Location.validate({
|
|
params: { id: "2baf70d1-42bb-4437-b551-e5fed5a87abe-1234" }
|
|
})
|
|
).toBe(false);
|
|
expect(
|
|
Location.validate({
|
|
params: { id: "2baf7e0d1-42bb-4437-b551-e5fed5a87abe" }
|
|
})
|
|
).toBe(false);
|
|
});
|
|
|
|
it("should dispatch getLocation action", async () => {
|
|
let wrapper = mount(Location, {
|
|
localVue,
|
|
store
|
|
});
|
|
|
|
await wrapper.vm.$options.asyncData({ store, params: $route.params });
|
|
expect(actions.getLocation).toHaveBeenCalled();
|
|
});
|
|
});
|