@@ -9,13 +9,18 @@ import { mount, createLocalVue, shallowMount } from "@vue/test-utils";
9
9
import * as All from "quasar" ;
10
10
const { Quasar, date } = All ;
11
11
12
+ /**
13
+ * @description : Testing functionality of HTML element mutations and actions
14
+ * `actions:` `addNestedHtml', `AddNestedNoActive`, `setActiveHTML`, `setActiveLayer`,
15
+ * `upOneLayer`, `deleteFromComponentHtmlList`, `deleteSelectedElement`
16
+ * `mutations: SET_ACTIVE_LAYER, UP_ONE_LAYER, ADD_TO_SELECTED_ELEMENT_LIST, SET_SELECTED_ELEMENT_LIST,
17
+ * ADD_TO_COMPONENT_HTML_LIST, ADD_NESTED_HTML, ADD_NESTED_NO_ACTIVE, DELETE_FROM_COMPONENT_HTML_LIST,
18
+ * DELETE_SELECTED_ELEMENT, SET_ACTIVE_HTML_ELEMENT
19
+ */
20
+
21
+
12
22
let hardA = {
13
23
componentName : "a" ,
14
- x : 0 ,
15
- y : 20 ,
16
- z : 0 ,
17
- w : 200 ,
18
- h : 200 ,
19
24
htmlList : [ {
20
25
children :[ {
21
26
children :[ {
@@ -54,8 +59,6 @@ const newState = {
54
59
NewView : [ ]
55
60
} ,
56
61
componentNameInputValue : '' ,
57
- projects : [ { filename : 'Untitled-1' , lastSavedLocation : '' } ] ,
58
-
59
62
activeRoute : 'HomeView' ,
60
63
activeComponent : '' ,
61
64
activeHTML : '' ,
@@ -65,14 +68,6 @@ const newState = {
65
68
} ,
66
69
67
70
selectedElementList : [ ] ,
68
- projectNumber : 2 ,
69
- activeTab : 0 ,
70
- componentChildrenMultiselectValue : [ ] ,
71
- modalOpen : false ,
72
- parentSelected : false ,
73
- imagePath : {
74
- HomeView : ''
75
- }
76
71
}
77
72
78
73
describe ( "Tests for navigating layers in HTML elements" , ( ) => {
@@ -226,20 +221,55 @@ describe("tests for HTML element actions", () => {
226
221
expect ( commit ) . toHaveBeenCalledWith ( "ADD_NESTED_HTML" , element ) ;
227
222
} ) ;
228
223
224
+ test ( '"[types.addNestedNoActive]" action calls the "ADD_NESTED_NO_ACTIVE" mutation' , ( ) => {
225
+ const element = {
226
+ date : Date . now ( ) ,
227
+ elementName : "div"
228
+ } ;
229
+ const commit = jest . fn ( ) ;
230
+ actions [ types . addNestedNoActive ] ( { commit } , element ) ;
231
+ expect ( commit ) . toHaveBeenCalledWith ( "ADD_NESTED_NO_ACTIVE" , element ) ;
232
+ } ) ;
233
+
234
+ test ( '"[types.setActiveHTML]" action calls the "SET_ACTIVE_HTML mutation' , ( ) => {
235
+ const element = [ 'div' , 0 , Date . now ( ) ] ;
236
+ const commit = jest . fn ( ) ;
237
+ actions [ types . setActiveHTML ] ( { commit } , element ) ;
238
+ expect ( commit ) . toHaveBeenCalledWith ( "SET_ACTIVE_HTML_ELEMENT" , element ) ;
239
+ } ) ;
240
+
229
241
test ( '"[types.setActiveLayer]" action calls the "SET_ACTIVE_LAYER" mutation' , ( ) => {
230
242
const element = { text : "form" , id : Date . now ( ) } ;
231
243
const commit = jest . fn ( ) ;
232
244
actions [ types . setActiveLayer ] ( { commit } , element ) ;
233
245
expect ( commit ) . toHaveBeenCalledWith ( "SET_ACTIVE_LAYER" , element ) ;
234
246
} ) ;
235
- } )
236
-
237
- // ADD NESTED HTML
238
- // ADD NESTED NO ACTIVE
239
- // SET ACTIVE HTML ELEMENT
240
- // ADD TO COMPONENT HTML LIST
241
- // DELETE FROM COMPONENT HTML LIST
242
- // ADD TO SELECTED ELEMENT LIST
243
- // SET SELECTED ELEMENT LIST
244
- // SET CLICKED ELEMENT LIST
245
- // DELETE SELECTED ELEMENT
247
+
248
+ test ( '"[types.upOneLayer]" action calls the "UP_ONE_LAYER" mutation' , ( ) => {
249
+ const id = Date . now ( ) ;
250
+ const commit = jest . fn ( ) ;
251
+ actions [ types . upOneLayer ] ( { commit } , id ) ;
252
+ expect ( commit ) . toHaveBeenCalledWith ( "UP_ONE_LAYER" , id ) ;
253
+ } ) ;
254
+
255
+ test ( '"[types.deleteFromComponentHtmlList]" action calls the "DELETE_FROM_COMPONENT_HTML_LIST" mutation' , ( ) => {
256
+ const id = Date . now ( ) ;
257
+ const commit = jest . fn ( ) ;
258
+ actions [ types . deleteFromComponentHtmlList ] ( { commit } , id ) ;
259
+ expect ( commit ) . toHaveBeenCalledWith ( "DELETE_FROM_COMPONENT_HTML_LIST" , id ) ;
260
+ } ) ;
261
+
262
+ test ( '"[types.deleteSelectedElement]" action calls the "DELETE_SELECTED_ELEMENT" mutation' , ( ) => {
263
+ const idx = 0 ;
264
+ const commit = jest . fn ( ) ;
265
+ actions [ types . deleteSelectedElement ] ( { commit } , idx ) ;
266
+ expect ( commit ) . toHaveBeenCalledWith ( "DELETE_SELECTED_ELEMENT" , idx ) ;
267
+ } ) ;
268
+
269
+ test ( '"[types.setClickedElementList]" action calls the "SET_CLICKED_ELEMENT_LIST" mutation' , ( ) => {
270
+ const element = { text : "form" , id : Date . now ( ) } ;
271
+ const commit = jest . fn ( ) ;
272
+ actions [ types . setClickedElementList ] ( { commit } , element ) ;
273
+ expect ( commit ) . toHaveBeenCalledWith ( "SET_CLICKED_ELEMENT_LIST" , element ) ;
274
+ } ) ;
275
+ } )
0 commit comments