@@ -6,24 +6,58 @@ import actions from "../../../src/store/actions";
6
6
import mutations from "../../../src/store/mutations" ;
7
7
import * as types from "../../../src/store/types" ;
8
8
import Vuex from "vuex" ;
9
- import store from "../../../src/store/state/index" ;
10
9
11
10
describe ( "Tests for copy and pasting" , ( ) => {
12
11
const App = { }
13
12
const app = createApp ( App ) ;
14
13
app . use ( Quasar , Vuex ) ;
15
- const state = { ...store }
14
+ let state ;
15
+ beforeEach ( ( ) => {
16
+ state = {
17
+ componentMap : {
18
+ testComp : {
19
+ componentName : "testComp" ,
20
+ children : [ ] ,
21
+ htmlList : [ ] ,
22
+ componentActions : [ ] ,
23
+ state : [ "state1" , "state2" ] ,
24
+ actions : [ "action1" , "action2" ]
25
+ }
26
+ } ,
27
+ activeComponent : "test" ,
28
+ userState : [ 'state1' , 'state2' ] ,
29
+ userActions : [ 'action1' , 'action2' ] ,
30
+ userProps : [ 'prop1' , 'prop2' ] ,
31
+ routes : {
32
+ HomeView : [ { componentName : 'testComp' , parent : [ ] } ] ,
33
+ } ,
34
+ activeRoute : 'HomeView' ,
35
+ pasteTimer : 0 ,
36
+ } ;
37
+ } ) ;
16
38
17
39
test ( '"[types.copyActiveComponent]" action to commit COPY_ACTIVE_COMPONENT' , ( ) => {
18
40
const commit = jest . fn ( ) ;
19
- actions [ types . copyActiveComponent ] ( { commit } , { } ) ;
20
- expect ( commit ) . toHaveBeenCalledWith ( types . COPY_ACTIVE_COMPONENT , { } ) ;
41
+ actions [ types . copyActiveComponent ] ( { commit } ) ;
42
+ expect ( commit ) . toHaveBeenCalledWith ( types . COPY_ACTIVE_COMPONENT ) ;
21
43
} ) ;
22
- test ( '"[types.pasteActiveComponent]" action to commit PASTE_ACTIVE_COMPONENT' , ( ) => {
23
- const commit = jest . fn ( ) ;
24
- actions [ types . pasteActiveComponent ] ( { commit } , { } ) ;
25
- expect ( commit ) . toHaveBeenCalledWith ( types . PASTE_ACTIVE_COMPONENT , { } ) ;
44
+
45
+ test ( '"[types.COPY_ACTIVE_COMPONENT]" to update state successfully' , ( ) => {
46
+ mutations [ types . SET_ACTIVE_COMPONENT ] ( state , 'testComp' ) ;
47
+ mutations [ types . COPY_ACTIVE_COMPONENT ] ( state ) ;
48
+ expect ( state . copiedComponent . componentName ) . toBe ( 'testComp' ) ;
49
+ } )
50
+
51
+ test ( '"[types.PASTE_ACTIVE_COMPONENT]" to update state successfully' , ( ) => {
52
+ mutations [ types . SET_ACTIVE_COMPONENT ] ( state , 'testComp' ) ;
53
+ mutations [ types . COPY_ACTIVE_COMPONENT ] ( state ) ;
54
+ mutations [ types . PASTE_ACTIVE_COMPONENT ] ( state ) ;
55
+ expect ( Object . keys ( state . componentMap ) . length ) . toBe ( 2 ) ;
26
56
} ) ;
27
57
58
+ test ( '"[types.PASTE_ACTIVE_COMPONENT]" to throttle via state paste timer' , ( ) => {
59
+ mutations [ types . UPDATE_PASTE_TIMER ] ( state ) ;
60
+ expect ( state . pasteTimer ) . not . toBe ( 0 ) ;
61
+ } ) ;
28
62
29
63
} ) ;
0 commit comments