Skip to content

Commit 91f32d2

Browse files
committed
finish testing updates for openProject.spec.js
1 parent c90151f commit 91f32d2

File tree

1 file changed

+71
-25
lines changed

1 file changed

+71
-25
lines changed

test/jest/__tests__/openProject.spec.js

Lines changed: 71 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// * = added to convert tests to OverVue 9.0, using Pinia instead of Vuex
12
import { mount, createLocalVue, shallowMount } from "@vue/test-utils";
23
import { createApp } from "vue";
34
import * as All from "quasar";
@@ -15,11 +16,11 @@ const components = Object.keys(All).reduce((object, key) => {
1516
return object;
1617
}, {});
1718

18-
import actions from "../../../src/store/options/actions";
19-
import mutations from "../../../src/store/options/mutations";
19+
// import actions from "../../../src/store/options/actions";
20+
// import mutations from "../../../src/store/options/mutations";
2021
import * as types from "../../../src/store/options/types";
21-
import Vuex from "vuex";
22-
import store from "../../../src/store/state/index";
22+
// import Vuex from "vuex";
23+
// import store from "../../../src/store/state/index";
2324

2425
/**
2526
* @description: Testing functionality of the openProject action and following mutations
@@ -118,32 +119,46 @@ describe("Test Suite for Image Upload", () => {
118119
imagePath: { HomeView: "/Users/joju/Desktop/bootstrap1.png", b: "" },
119120
};
120121

121-
test('"[types.openProject]" action calls set_image_path, set_component_map, and set_routes', () => {
122-
const commit = jest.fn();
123-
actions[types.openProject]({ commit }, payload);
124-
expect(commit).toHaveBeenCalledWith("SET_IMAGE_PATH", payload.imagePath);
125-
expect(commit).toHaveBeenCalledWith(
126-
"SET_COMPONENT_MAP",
127-
payload.componentMap
128-
);
129-
expect(commit).toHaveBeenCalledWith("SET_ROUTES", payload.routes);
130-
expect(commit).toHaveBeenCalledWith("REMOVE_ALL_STATE_PROPS_ACTIONS");
131-
expect(commit).toHaveBeenCalledWith("SET_ACTIVE_ROUTE", "HomeView");
132-
expect(commit).toHaveBeenCalledWith("SET_ACTIVE_COMPONENT", "");
133-
});
122+
// test('"[types.openProject]" action calls set_image_path, set_component_map, and set_routes', () => {
123+
// const commit = jest.fn();
124+
// actions[types.openProject]({ commit }, payload);
125+
// expect(commit).toHaveBeenCalledWith("SET_IMAGE_PATH", payload.imagePath);
126+
// expect(commit).toHaveBeenCalledWith(
127+
// "SET_COMPONENT_MAP",
128+
// payload.componentMap
129+
// );
130+
// expect(commit).toHaveBeenCalledWith("SET_ROUTES", payload.routes);
131+
// expect(commit).toHaveBeenCalledWith("REMOVE_ALL_STATE_PROPS_ACTIONS");
132+
// expect(commit).toHaveBeenCalledWith("SET_ACTIVE_ROUTE", "HomeView");
133+
// expect(commit).toHaveBeenCalledWith("SET_ACTIVE_COMPONENT", "");
134+
// });
134135

135136
test('"[types.SET_IMAGE_PATH]" mutation expect add payload to imagePath object in state', () => {
136137
const openState = {
137138
imagePath: {
138139
HomeView: "",
139140
},
140141
};
141-
mutations[types.SET_IMAGE_PATH](openState, payload.imagePath);
142-
expect(openState.imagePath).toMatchObject({
142+
piniaStore.setImagePath(payload.imagePath);
143+
expect(piniaStore.imagePath).toMatchObject({
143144
...openState.imagePath,
144145
...payload.imagePath,
145146
});
146147
});
148+
149+
// test('"[types.SET_IMAGE_PATH]" mutation expect add payload to imagePath object in state', () => {
150+
// const openState = {
151+
// imagePath: {
152+
// HomeView: "",
153+
// },
154+
// };
155+
// mutations[types.SET_IMAGE_PATH](openState, payload.imagePath);
156+
// expect(openState.imagePath).toMatchObject({
157+
// ...openState.imagePath,
158+
// ...payload.imagePath,
159+
// });
160+
// });
161+
147162
test('"[types.SET_COMPONENT_MAP]" mutation expect state.componentMap object to match payload.componentMap', () => {
148163
const openState = {
149164
componentMap: {
@@ -159,17 +174,48 @@ describe("Test Suite for Image Upload", () => {
159174
},
160175
},
161176
};
162-
mutations[types.SET_COMPONENT_MAP](openState, payload.componentMap);
163-
expect(openState.componentMap).toMatchObject(payload.componentMap);
177+
piniaStore.setComponentMap(payload.componentMap);
178+
expect(piniaStore.componentMap).toMatchObject(payload.componentMap);
164179
});
180+
181+
// test('"[types.SET_COMPONENT_MAP]" mutation expect state.componentMap object to match payload.componentMap', () => {
182+
// const openState = {
183+
// componentMap: {
184+
// App: {
185+
// componentName: "App",
186+
// children: ["HomeView"],
187+
// htmlList: [],
188+
// },
189+
// HomeView: {
190+
// componentName: "HomeView",
191+
// children: [],
192+
// htmlList: [],
193+
// },
194+
// },
195+
// };
196+
// mutations[types.SET_COMPONENT_MAP](openState, payload.componentMap);
197+
// expect(openState.componentMap).toMatchObject(payload.componentMap);
198+
// });
199+
165200
test('"[types.SET_ROUTES]" mutation expect state.routes object to match payload.routes ', () => {
166201
const openState = {
167202
routes: {
168203
HomeView: [],
169204
},
170205
};
171-
172-
mutations[types.SET_ROUTES](openState, payload.routes);
173-
expect(openState.routes).toMatchObject(payload.routes);
206+
piniaStore.setRoutes(payload.routes);
207+
expect(piniaStore.routes).toMatchObject(payload.routes);
174208
});
175-
});
209+
210+
// test('"[types.SET_ROUTES]" mutation expect state.routes object to match payload.routes ', () => {
211+
// const openState = {
212+
// routes: {
213+
// HomeView: [],
214+
// },
215+
// };
216+
217+
// mutations[types.SET_ROUTES](openState, payload.routes);
218+
// expect(openState.routes).toMatchObject(payload.routes);
219+
// });
220+
221+
});

0 commit comments

Comments
 (0)