1
+ // * = added to convert tests to OverVue 9.0, using Pinia instead of Vuex
1
2
import { mount , createLocalVue , shallowMount } from "@vue/test-utils" ;
2
3
import { createApp } from "vue" ;
3
4
import * as All from "quasar" ;
@@ -15,11 +16,11 @@ const components = Object.keys(All).reduce((object, key) => {
15
16
return object ;
16
17
} , { } ) ;
17
18
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";
20
21
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";
23
24
24
25
/**
25
26
* @description : Testing functionality of the openProject action and following mutations
@@ -118,32 +119,46 @@ describe("Test Suite for Image Upload", () => {
118
119
imagePath : { HomeView : "/Users/joju/Desktop/bootstrap1.png" , b : "" } ,
119
120
} ;
120
121
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
+ // });
134
135
135
136
test ( '"[types.SET_IMAGE_PATH]" mutation expect add payload to imagePath object in state' , ( ) => {
136
137
const openState = {
137
138
imagePath : {
138
139
HomeView : "" ,
139
140
} ,
140
141
} ;
141
- mutations [ types . SET_IMAGE_PATH ] ( openState , payload . imagePath ) ;
142
- expect ( openState . imagePath ) . toMatchObject ( {
142
+ piniaStore . setImagePath ( payload . imagePath ) ;
143
+ expect ( piniaStore . imagePath ) . toMatchObject ( {
143
144
...openState . imagePath ,
144
145
...payload . imagePath ,
145
146
} ) ;
146
147
} ) ;
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
+
147
162
test ( '"[types.SET_COMPONENT_MAP]" mutation expect state.componentMap object to match payload.componentMap' , ( ) => {
148
163
const openState = {
149
164
componentMap : {
@@ -159,17 +174,48 @@ describe("Test Suite for Image Upload", () => {
159
174
} ,
160
175
} ,
161
176
} ;
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 ) ;
164
179
} ) ;
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
+
165
200
test ( '"[types.SET_ROUTES]" mutation expect state.routes object to match payload.routes ' , ( ) => {
166
201
const openState = {
167
202
routes : {
168
203
HomeView : [ ] ,
169
204
} ,
170
205
} ;
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 ) ;
174
208
} ) ;
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