Add basic Vue logic to Vehicles/Locations/People
This commit is contained in:
56
pages/locations/_id.spec.js
Normal file
56
pages/locations/_id.spec.js
Normal file
@@ -0,0 +1,56 @@
|
||||
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();
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user