2
2
/**
3
3
* @jest -environment jsdom
4
4
*/
5
- import mutations from "../../../src/store/options/mutations" ;
6
- import actions from "../../../src/store/options/actions" ;
7
- import { mount , createLocalVue , shallowMount } from "@vue/test-utils" ;
8
- import * as All from "quasar" ;
9
- const { Quasar, date } = All ;
5
+ // import mutations from "../../../src/store/options/mutations";
6
+ import { setActivePinia , createPinia } from 'pinia'
7
+ import { useStore } from "src/store/main.js" ;
8
+ const store = useStore ( ) ;
10
9
11
10
/**
12
11
* @description : Tests for deleting state
@@ -17,37 +16,64 @@ const { Quasar, date } = All;
17
16
*/
18
17
19
18
describe ( "Delete state/actions in userStore/componentMap" , ( ) => {
20
- let state ;
21
19
beforeEach ( ( ) => {
22
- state = {
23
- componentMap : {
24
- testComp : {
25
- componentName : "test" ,
26
- children : [ ] ,
27
- htmlList : [ ] ,
28
- componentActions : [ ] ,
29
- state : [ "state1" , "state2" ] ,
30
- actions : [ "action1" , "action2" ] ,
31
- } ,
32
- } ,
33
- activeComponent : "test" ,
34
- userState : [ "state1" , "state2" ] ,
35
- userActions : [ "action1" , "action2" ] ,
36
- userProps : [ "prop1" , "prop2" ] ,
37
- } ;
20
+ store . componentMap = {
21
+ testComp : {
22
+ componentName : "test" ,
23
+ children : [ ] ,
24
+ htmlList : [ ] ,
25
+ componentActions : [ ] ,
26
+ state : [ "state1" , "state2" ] ,
27
+ actions : [ "action1" , "action2" ] ,
28
+ }
29
+ }
30
+ store . activeComponent = "test" ;
31
+ store . userState = [ "state1" , "state2" ] ;
32
+ store . userActions = [ "action1" , "action2" ] ;
33
+ store . userProps = [ "prop1" , "prop2" ] ;
34
+ // state = {
35
+ // componentMap: {
36
+ // testComp: {
37
+ // componentName: "test",
38
+ // children: [],
39
+ // htmlList: [],
40
+ // componentActions: [],
41
+ // state: ["state1", "state2"],
42
+ // actions: ["action1", "action2"],
43
+ // },
44
+ // },
45
+ // activeComponent: "test",
46
+ // userState: ["state1", "state2"],
47
+ // userActions: ["action1", "action2"],
48
+ // userProps: ["prop1", "prop2"],
49
+ // };
38
50
} ) ;
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" ] ) ;
51
+ // test("'[types.DELETE_USER_STATE]' should delete a single state property", () => {
52
+ // mutations.DELETE_USER_STATE(state, "state1");
53
+ // expect(state.userState).toEqual(["state2"]);
54
+ // });
55
+ test ( "function deleteUserState should delete a single state property" , ( ) => {
56
+ store . deleteUserState ( "state1" ) ;
57
+ expect ( store . userState ) . toEqual ( [ "state2" ] ) ;
42
58
} ) ;
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" ] ) ;
59
+ // test("'[types.DELETE_USER_ACTIONS]' should delete a single action property", () => {
60
+ // mutations.DELETE_USER_ACTIONS(state, "action1");
61
+ // expect(state.userActions).toEqual(["action2"]);
62
+ // });
63
+ test ( "'function deleteUserActions should delete a single action property" , ( ) => {
64
+ store . deleteUserActions ( "action1" ) ;
65
+ expect ( store . userActions ) . toEqual ( [ "action2" ] ) ;
46
66
} ) ;
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 ) ;
67
+ // test("'[types.REMOVE_ALL_STATE_PROPS_ACTIONS]' should delete all props, state and action", () => {
68
+ // mutations.REMOVE_ALL_STATE_PROPS_ACTIONS(state);
69
+ // expect(state.userState.length).toEqual(0);
70
+ // expect(state.userActions.length).toEqual(0);
71
+ // expect(state.userProps.length).toEqual(0);
72
+ // });
73
+ test ( " function removeAllStatePropsActions should delete all props, state and action" , ( ) => {
74
+ store . removeAllStatePropsActions ( ) ;
75
+ expect ( store . userState . length ) . toEqual ( 0 ) ;
76
+ expect ( store . userActions . length ) . toEqual ( 0 ) ;
77
+ expect ( store . userProps . length ) . toEqual ( 0 ) ;
52
78
} ) ;
53
79
} ) ;
0 commit comments