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" ;
4
5
const { Quasar, date } = All ;
5
6
7
+ import { createTestingPinia } from "@pinia/testing" ; // *
8
+ import { useStore } from "../../src/store/main" ; // *
9
+ const piniaStore = useStore ( ) ; // *
10
+
6
11
const components = Object . keys ( All ) . reduce ( ( object , key ) => {
7
12
const val = All [ key ] ;
8
13
if ( val && val . component && val . component . name != null ) {
@@ -11,11 +16,11 @@ const components = Object.keys(All).reduce((object, key) => {
11
16
return object ;
12
17
} , { } ) ;
13
18
14
- import actions from "../../../src/store/options/actions" ;
15
- import mutations from "../../../src/store/options/mutations" ;
19
+ // import actions from "../../../src/store/options/actions";
20
+ // import mutations from "../../../src/store/options/mutations";
16
21
import * as types from "../../../src/store/options/types" ;
17
- import Vuex from "vuex" ;
18
- import store from "../../../src/store/state/index" ;
22
+ // import Vuex from "vuex";
23
+ // import store from "../../../src/store/state/index";
19
24
20
25
/**
21
26
* @description : Testing functionality of the openProject action and following mutations
@@ -27,7 +32,8 @@ import store from "../../../src/store/state/index";
27
32
describe ( "Test Suite for Image Upload" , ( ) => {
28
33
const App = { } ;
29
34
const app = createApp ( App ) ;
30
- app . use ( Quasar , Vuex , { components } ) ;
35
+ app . use ( Quasar , piniaStore , { components } ) ; // *
36
+ // app.use(Quasar, Vuex, { components });
31
37
const payload = {
32
38
icons : {
33
39
div : "far fa-square fa-lg" ,
@@ -113,32 +119,46 @@ describe("Test Suite for Image Upload", () => {
113
119
imagePath : { HomeView : "/Users/joju/Desktop/bootstrap1.png" , b : "" } ,
114
120
} ;
115
121
116
- test ( '"[types.openProject]" action calls set_image_path, set_component_map, and set_routes' , ( ) => {
117
- const commit = jest . fn ( ) ;
118
- actions [ types . openProject ] ( { commit } , payload ) ;
119
- expect ( commit ) . toHaveBeenCalledWith ( "SET_IMAGE_PATH" , payload . imagePath ) ;
120
- expect ( commit ) . toHaveBeenCalledWith (
121
- "SET_COMPONENT_MAP" ,
122
- payload . componentMap
123
- ) ;
124
- expect ( commit ) . toHaveBeenCalledWith ( "SET_ROUTES" , payload . routes ) ;
125
- expect ( commit ) . toHaveBeenCalledWith ( "REMOVE_ALL_STATE_PROPS_ACTIONS" ) ;
126
- expect ( commit ) . toHaveBeenCalledWith ( "SET_ACTIVE_ROUTE" , "HomeView" ) ;
127
- expect ( commit ) . toHaveBeenCalledWith ( "SET_ACTIVE_COMPONENT" , "" ) ;
128
- } ) ;
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
+ // });
129
135
130
136
test ( '"[types.SET_IMAGE_PATH]" mutation expect add payload to imagePath object in state' , ( ) => {
131
137
const openState = {
132
138
imagePath : {
133
139
HomeView : "" ,
134
140
} ,
135
141
} ;
136
- mutations [ types . SET_IMAGE_PATH ] ( openState , payload . imagePath ) ;
137
- expect ( openState . imagePath ) . toMatchObject ( {
142
+ piniaStore . setImagePath ( payload . imagePath ) ;
143
+ expect ( piniaStore . imagePath ) . toMatchObject ( {
138
144
...openState . imagePath ,
139
145
...payload . imagePath ,
140
146
} ) ;
141
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
+
142
162
test ( '"[types.SET_COMPONENT_MAP]" mutation expect state.componentMap object to match payload.componentMap' , ( ) => {
143
163
const openState = {
144
164
componentMap : {
@@ -154,17 +174,48 @@ describe("Test Suite for Image Upload", () => {
154
174
} ,
155
175
} ,
156
176
} ;
157
- mutations [ types . SET_COMPONENT_MAP ] ( openState , payload . componentMap ) ;
158
- expect ( openState . componentMap ) . toMatchObject ( payload . componentMap ) ;
177
+ piniaStore . setComponentMap ( payload . componentMap ) ;
178
+ expect ( piniaStore . componentMap ) . toMatchObject ( payload . componentMap ) ;
159
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
+
160
200
test ( '"[types.SET_ROUTES]" mutation expect state.routes object to match payload.routes ' , ( ) => {
161
201
const openState = {
162
202
routes : {
163
203
HomeView : [ ] ,
164
204
} ,
165
205
} ;
166
-
167
- mutations [ types . SET_ROUTES ] ( openState , payload . routes ) ;
168
- expect ( openState . routes ) . toMatchObject ( payload . routes ) ;
206
+ piniaStore . setRoutes ( payload . routes ) ;
207
+ expect ( piniaStore . routes ) . toMatchObject ( payload . routes ) ;
169
208
} ) ;
170
- } ) ;
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