|
1 |
| -import { mount, shallowMount } from "@vue/test-utils"; |
| 1 | +// import { mount, shallowMount } from "@vue/test-utils"; |
2 | 2 | import { createApp } from "vue";
|
3 | 3 | import * as All from "quasar";
|
| 4 | +import { setActivePinia, createPinia } from 'pinia' |
| 5 | +import * as types from "../../../types"; |
| 6 | +import { useStore } from "src/store/main.js"; |
| 7 | +// import Vuex from "vuex"; |
4 | 8 | const { Quasar, date } = All;
|
5 |
| -import actions from "../../../src/store/options/actions"; |
6 |
| -import mutations from "../../../src/store/options/mutations"; |
7 |
| -import * as types from "../../../src/store/options/types"; |
8 |
| -import Vuex from "vuex"; |
| 9 | +// import actions from "../../../src/store/options/actions"; |
| 10 | +// import mutations from "../../../src/store/options/mutations"; |
| 11 | +// import * as types from "../../../src/store/options/types"; |
9 | 12 |
|
10 | 13 | describe("Tests for copy and pasting", () => {
|
11 | 14 | const App = {};
|
12 | 15 | const app = createApp(App);
|
13 |
| - app.use(Quasar, Vuex); |
14 |
| - let state; |
| 16 | + const pinia = setActivePinia(createPinia()); |
| 17 | + app.use(Quasar, pinia); |
| 18 | + // app.use(Quasar, Vuex); |
| 19 | +const store = useStore(); |
| 20 | + // let state; |
15 | 21 | 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 |
| - }); |
| 22 | + store.componentMap = { |
| 23 | + testComp: { |
| 24 | + componentName: "testComp", |
| 25 | + children: [], |
| 26 | + htmlList: [], |
| 27 | + componentActions: [], |
| 28 | + state: ["state1", "state2"], |
| 29 | + actions: ["action1", "action2"], |
| 30 | + } |
| 31 | + }; |
| 32 | + store.activeComponent = "test"; |
| 33 | + store.userState = ["state1", "state2"]; |
| 34 | + store.userActions = ["action1", "action2"]; |
| 35 | + store.userProps = ["prop1", "prop2"]; |
| 36 | + store.routes = { |
| 37 | + HomeView: [{ componentName: "testComp", parent: [] }] |
| 38 | + }; |
| 39 | + store.activeRoute = "HomeView"; |
| 40 | + store.pasteTimer = 0; |
| 41 | + }); |
| 42 | + // state = { |
| 43 | + // componentMap: { |
| 44 | + // testComp: { |
| 45 | + // componentName: "testComp", |
| 46 | + // children: [], |
| 47 | + // htmlList: [], |
| 48 | + // componentActions: [], |
| 49 | + // state: ["state1", "state2"], |
| 50 | + // actions: ["action1", "action2"], |
| 51 | + // }, |
| 52 | + // }, |
| 53 | + // activeComponent: "test", |
| 54 | + // userState: ["state1", "state2"], |
| 55 | + // userActions: ["action1", "action2"], |
| 56 | + // userProps: ["prop1", "prop2"], |
| 57 | + // routes: { |
| 58 | + // HomeView: [{ componentName: "testComp", parent: [] }], |
| 59 | + // }, |
| 60 | + // activeRoute: "HomeView", |
| 61 | + // pasteTimer: 0, |
| 62 | + // }; |
38 | 63 |
|
39 |
| - test('"[types.copyActiveComponent]" action to commit COPY_ACTIVE_COMPONENT', () => { |
40 |
| - const commit = jest.fn(); |
41 |
| - actions[types.copyActiveComponent]({ commit }); |
42 |
| - expect(commit).toHaveBeenCalledWith(types.COPY_ACTIVE_COMPONENT); |
43 |
| - }); |
44 | 64 |
|
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"); |
| 65 | + // test('"[types.copyActiveComponent]" action to commit COPY_ACTIVE_COMPONENT', () => { |
| 66 | + // const commit = jest.fn(); |
| 67 | + // actions[types.copyActiveComponent]({ commit }); |
| 68 | + // expect(commit).toHaveBeenCalledWith(types.COPY_ACTIVE_COMPONENT); |
| 69 | + // }); |
| 70 | + |
| 71 | + test('"function copyActiveComponent to update state successfully', () => { |
| 72 | + store.setActiveComponent("testComp"); |
| 73 | + store.copyActiveComponent; |
| 74 | + expect(store.copiedComponent.componentName).toBe("testComp"); |
49 | 75 | });
|
50 | 76 |
|
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); |
| 77 | + // test('"[types.COPY_ACTIVE_COMPONENT]" to update state successfully', () => { |
| 78 | + // mutations[types.SET_ACTIVE_COMPONENT](state, "testComp"); |
| 79 | + // mutations[types.COPY_ACTIVE_COMPONENT](state); |
| 80 | + // expect(state.copiedComponent.componentName).toBe("testComp"); |
| 81 | + // }); |
| 82 | + |
| 83 | + |
| 84 | + test('"function pasteActiveComponent to update state successfully', () => { |
| 85 | + store.setActiveComponent("testComp"); |
| 86 | + store.copyActiveComponent(); |
| 87 | + store.pasteActiveComponent(); |
| 88 | + expect(Object.keys(store.componentMap).length).toBe(2); |
56 | 89 | });
|
57 | 90 |
|
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); |
| 91 | + // test('"[types.PASTE_ACTIVE_COMPONENT]" to update state successfully', () => { |
| 92 | + // mutations[types.SET_ACTIVE_COMPONENT](state, "testComp"); |
| 93 | + // mutations[types.COPY_ACTIVE_COMPONENT](state); |
| 94 | + // mutations[types.PASTE_ACTIVE_COMPONENT](state); |
| 95 | + // expect(Object.keys(state.componentMap).length).toBe(2); |
| 96 | + // }); |
| 97 | + |
| 98 | + test('function pasteActiveComponent to throttle via state paste timer', () => { |
| 99 | + store.updatePasteTimer(); |
| 100 | + expect(store.pasteTimer).not.toBe(0); |
61 | 101 | });
|
| 102 | + |
| 103 | + // test('"[types.PASTE_ACTIVE_COMPONENT]" to throttle via state paste timer', () => { |
| 104 | + // mutations[types.UPDATE_PASTE_TIMER](state); |
| 105 | + // expect(state.pasteTimer).not.toBe(0); |
| 106 | + // }); |
62 | 107 | });
|
0 commit comments