@@ -8,167 +8,6 @@ import { mount, createLocalVue, shallowMount } from "@vue/test-utils";
8
8
import * as All from "quasar" ;
9
9
const { Quasar, date } = All ;
10
10
11
- describe ( "Test mutations + actions to remove action from component and userActions" , ( ) => {
12
- let state ;
13
- beforeEach ( ( ) => {
14
- // state = {
15
- // componentMap: {
16
- // component: {
17
- // componentName: "App",
18
- // children: ["HomeView"],
19
- // htmlList: [],
20
- // mapActions: ["action"]
21
- // }
22
- // },
23
- // activeComponent: "component",
24
- // userActions: ["action"]
25
- // };
26
- state = {
27
- // state below is what is used when exporting a project
28
- componentMap : {
29
- App : {
30
- componentName : 'component' ,
31
- children : [ 'HomeView' ] ,
32
- htmlList : [ ]
33
- } ,
34
- HomeView : {
35
- componentName : 'HomeView' ,
36
- children : [ ] ,
37
- htmlList : [ ]
38
- }
39
- } ,
40
- routes : {
41
- HomeView : [ ]
42
- } ,
43
- userActions : [ ] ,
44
- userProps : [ ] ,
45
- userState : [ ] ,
46
- imagePath : {
47
- HomeView : ''
48
- } ,
49
- // state below is not used when exporting a project
50
- componentNameInputValue : '' ,
51
- projects : [ { filename : 'Untitled-1' , lastSavedLocation : '' } ] ,
52
-
53
- activeRoute : 'HomeView' ,
54
- // need to change to activeComponentName
55
- activeComponent : '' ,
56
- activeComponentObj : null ,
57
- activeHTML : '' ,
58
- activeLayer : {
59
- id : '' ,
60
- lineage : [ ]
61
- } ,
62
-
63
- selectedProps : [ ] ,
64
- selectedState : [ ] ,
65
- selectedActions : [ ] ,
66
- selectedElementList : [ ] ,
67
- projectNumber : 2 ,
68
- activeTab : 0 ,
69
- componentChildrenMultiselectValue : [ ] ,
70
- modalOpen : false ,
71
- parentSelected : false ,
72
- // for storing copied component
73
- copiedComponent : { } ,
74
- copyNumber : 0 ,
75
- pastedComponent : { }
76
- }
77
- } ) ;
78
-
79
- it ( "deleting user action from state.userActions" , ( ) => {
80
- mutations . DELETE_USER_ACTIONS ( state , "action" ) ;
81
- expect ( state . userActions . length ) . toBe ( 0 ) ;
82
- } ) ;
83
-
84
- // it('deleting "action" from componentMap', () => {
85
- // mutations.REMOVE_ACTION_FROM_COMPONENT(state, "action");
86
- // expect(state.componentMap.component.mapActions.length).toBe(0);
87
- // });
88
- } ) ;
89
-
90
- describe ( "Adding actions and state to components" , ( ) => {
91
- let state ;
92
- beforeEach ( ( ) => {
93
- state = {
94
- componentMap : {
95
- testComponent : {
96
- componentName : "testComponent" ,
97
- children : [ ] ,
98
- htmlList : [ ] ,
99
- componentActions : [ ] ,
100
- componentState : [ ]
101
- }
102
- } ,
103
- activeComponent : "testComponent"
104
- } ;
105
- } ) ;
106
- describe ( "Adding actions to components" , ( ) => {
107
- // it("should add a single action to active component", () => {
108
- // mutations.ADD_TO_COMPONENT_ACTIONS(state, "testAction");
109
- // expect(
110
- // state.componentMap[state.activeComponent].componentActions
111
- // ).toEqual(["testAction"]);
112
- // });
113
- } ) ;
114
- describe ( "Adding state to components" , ( ) => {
115
- it ( "should add a single state string to active component" , ( ) => {
116
- // mutations.ADD_TO_COMPONENT_STATE(state, "testState");
117
- // expect(state.componentMap[state.activeComponent].componentState).toEqual([
118
- // "testState"
119
- // ]);
120
- } ) ;
121
- } ) ;
122
- } ) ;
123
-
124
- // describe("userActions mutation", () => {
125
- // let actions;
126
- // let store;
127
- // beforeEach(() => {
128
- // store = {
129
- // userActions: []
130
- // };
131
- // });
132
- // it("should push user defined action to end of userActions array", () => {
133
- // // mutations.ADD_USER_ACTION(store, "actionnnn");
134
- // // expect(store.userActions[store.userActions.length - 1]).toBe("actionnnn");
135
- // // });
136
- // it("should only push to array if payload is of type string", () => {
137
- // // mutations.ADD_USER_ACTION(store, 66);
138
- // // expect(store.userActions).toStrictEqual([]);
139
- // // });
140
- // });
141
-
142
- // describe("userStore mutation", () => {
143
- // let actions;
144
- // let store;
145
- // store = {
146
- // userStore: {}
147
- // };
148
- // it("should be able to update store with a key defined by the user and a value of type object", () => {
149
- // mutations.ADD_TO_USER_STORE(store, { dummyKey: {} });
150
- // // console.log('store.userStore.dummyKey', store.userStore.dummyKey);
151
- // expect(store.userStore.dummyKey).toStrictEqual({});
152
- // });
153
- // it("should update user store with a key value pair with value strictly equal to empty array", () => {
154
- // mutations.ADD_TO_USER_STORE(store, { dummyKey: [] });
155
- // expect(store.userStore.dummyKey).toStrictEqual([]);
156
- // });
157
- // it("should be able to store booleans in the store as the key", () => {
158
- // mutations.ADD_TO_USER_STORE(store, { boolean: true });
159
- // expect(store.userStore.boolean).toBe(true);
160
- // });
161
- // it("should add to userStore a key with a value of type number", () => {
162
- // mutations.ADD_TO_USER_STORE(store, { number: 696 });
163
- // expect(store.userStore.number).toBe(696);
164
- // });
165
-
166
- // it("should work with strings too", () => {
167
- // mutations.ADD_TO_USER_STORE(store, { string: "string" });
168
- // expect(store.userStore.string).toBe("string");
169
- // });
170
- // });
171
-
172
11
/**
173
12
* @description : Tests for deleting state
174
13
* @summary :
@@ -177,42 +16,40 @@ describe("Adding actions and state to components", () => {
177
16
* `userStore` holds the user defined state objects
178
17
*/
179
18
180
- describe ( "Delete state in userStore/componentMap" , ( ) => {
19
+ describe ( "Delete state/actions in userStore/componentMap" , ( ) => {
181
20
let state ;
182
21
beforeEach ( ( ) => {
183
22
state = {
184
23
componentMap : {
185
- test : {
24
+ testComp : {
186
25
componentName : "test" ,
187
26
children : [ ] ,
188
27
htmlList : [ ] ,
189
28
componentActions : [ ] ,
190
- state : [ "state1" , "state2" ]
29
+ state : [ "state1" , "state2" ] ,
30
+ actions : [ "action1" , "action2" ]
191
31
}
192
32
} ,
193
33
activeComponent : "test" ,
194
- userState : [ 'state1' , 'state2' ]
34
+ userState : [ 'state1' , 'state2' ] ,
35
+ userActions : [ 'action1' , 'action2' ] ,
36
+ userProps : [ 'prop1' , 'prop2' ]
195
37
} ;
196
38
} ) ;
197
- describe ( '"DELETE_USER_STATE" should delete property from "userStore" object' , ( ) => {
198
- it ( "should delete a single state property" , ( ) => {
199
- mutations . DELETE_USER_STATE ( state , "state1" ) ;
200
- expect ( state . userState ) . toEqual ( [ 'state2' ] ) ;
201
- } ) ;
39
+ test ( "'[types.DELETE_USER_STATE]' should delete a single state property" , ( ) => {
40
+ mutations . DELETE_USER_STATE ( state , "state1" ) ;
41
+ expect ( state . userState ) . toEqual ( [ 'state2' ] ) ;
42
+ } ) ;
43
+ test ( "'[types.DELETE_USER_ACTIONS]' should delete a single action property" , ( ) => {
44
+ mutations . DELETE_USER_ACTIONS ( state , "action1" ) ;
45
+ expect ( state . userActions ) . toEqual ( [ 'action2' ] ) ;
202
46
} ) ;
203
- // describe('"REMOVE_STATE_FROM_COMPONENT" should delete state in "activeComponent"', () => {
204
- // it("should remove state from active component", () => {
205
- // mutations.REMOVE_STATE_FROM_COMPONENT(state, "state2");
206
- // expect(state.componentMap.test.componentState).toEqual(["state1"]);
207
- // });
208
- // });
209
- // describe('"deleteUserState" should delete state in "activeComponent" when deleted from "userStore"', () => {
210
- // const commit = jest.fn();
211
- // it("should remove state from active component", () => {
212
- // actions.deleteUserState({ commit }, "state2");
213
- // expect(state.componentMap[state.activeComponent].componentState).toEqual([
214
- // "state1"
215
- // ]);
216
- // });
217
- // });
47
+ test ( "'[types.REMOVE_ALL_STATE_PROPS_ACTIONS]' should delete all props, state and action" , ( ) => {
48
+ mutations . REMOVE_ALL_STATE_PROPS_ACTIONS ( state ) ;
49
+ expect ( state . userState . length ) . toEqual ( 0 ) ;
50
+ expect ( state . userActions . length ) . toEqual ( 0 ) ;
51
+ expect ( state . userProps . length ) . toEqual ( 0 ) ;
52
+ } ) ;
53
+
218
54
} ) ;
55
+
0 commit comments