|
1 | 1 | import { mount, shallowMount } from "@vue/test-utils";
|
2 | 2 | import { createApp } from "vue";
|
| 3 | +import { createTestingPinia } from "@pinia/testing"; |
3 | 4 | import * as All from "quasar";
|
4 | 5 | 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 store from "../../../src/store/state/index"; |
| 6 | +import { useStore } from "../../../store/main.js"; |
10 | 7 |
|
| 8 | +const store = useStore(); |
11 | 9 | //testing that export as typescript on/off, showTutorial, all update properly
|
12 | 10 | describe("Test for exportAsTypescript flag to flip when mutation committed", () => {
|
13 | 11 | const App = {};
|
14 | 12 | const app = createApp(App);
|
15 |
| - app.use(Quasar, Vuex); |
16 |
| - const state = { ...store }; |
| 13 | + app.use(Quasar); |
17 | 14 |
|
18 | 15 | //tests that the export as typescript mutation properly updates state to on/off
|
19 |
| - test('"[types.EXPORT_AS_TYPESCRIPT]" to update state successfully', () => { |
20 |
| - mutations[types.EXPORT_AS_TYPESCRIPT](state, "on"); |
21 |
| - expect(state.exportAsTypescript).toEqual("on"); |
22 |
| - mutations[types.EXPORT_AS_TYPESCRIPT](state, "off"); |
23 |
| - expect(state.exportAsTypescript).toEqual("off"); |
| 16 | + test('"store.ExportAsTypescript" to update state successfully', () => { |
| 17 | + store.ExportAsTypescript("on"); |
| 18 | + expect(this.ExportAsTypescript).toEqual("on"); |
| 19 | + store.ExportAsTypescript("off"); |
| 20 | + expect(this.exportAsTypescript).toEqual("off"); |
24 | 21 | });
|
25 | 22 |
|
26 |
| - //tests that the tutorial toggle successfully updates state to true/false |
27 |
| - test('"[types.toggleTutorial]" action to commit TOGGLE_TUTORIAL', () => { |
28 |
| - const commit = jest.fn(); |
29 |
| - actions[types.toggleTutorial]({ state, commit }); |
30 |
| - expect(commit).toHaveBeenCalledWith(types.TOGGLE_TUTORIAL); |
31 |
| - }); |
32 |
| - |
33 |
| - test('"[types.TOGGLE_TUTORIAL]" to mutate state true/false', () => { |
34 |
| - mutations[types.TOGGLE_TUTORIAL](state); |
35 |
| - expect(state.showTutorial).toBe(false); |
36 |
| - mutations[types.TOGGLE_TUTORIAL](state); |
37 |
| - expect(state.showTutorial).toBe(true); |
| 23 | + test('"store.toggleTutorial" to mutate state true/false', () => { |
| 24 | + store.toggleTutorial(); |
| 25 | + expect(this.showTutorial).toBe(false); |
| 26 | + store.toggleTutorial(); |
| 27 | + expect(this.showTutorial).toBe(true); |
38 | 28 | });
|
39 | 29 | });
|
| 30 | + |
| 31 | + |
| 32 | + |
| 33 | + |
| 34 | +// old VueX testing |
| 35 | +// import { mount, shallowMount } from "@vue/test-utils"; |
| 36 | +// import { createApp } from "vue"; |
| 37 | +// import * as All from "quasar"; |
| 38 | +// const { Quasar, date } = All; |
| 39 | +// import actions from "../../../src/store/options/actions"; |
| 40 | +// import mutations from "../../../src/store/options/mutations"; |
| 41 | +// import * as types from "../../../src/store/options/types"; |
| 42 | +// import Vuex from "vuex"; |
| 43 | +// import store from "../../../src/store/state/index"; |
| 44 | + |
| 45 | +// //testing that export as typescript on/off, showTutorial, all update properly |
| 46 | +// describe("Test for exportAsTypescript flag to flip when mutation committed", () => { |
| 47 | +// const App = {}; |
| 48 | +// const app = createApp(App); |
| 49 | +// app.use(Quasar, Vuex); |
| 50 | +// const state = { ...store }; |
| 51 | + |
| 52 | +// //tests that the export as typescript mutation properly updates state to on/off |
| 53 | +// test('"[types.EXPORT_AS_TYPESCRIPT]" to update state successfully', () => { |
| 54 | +// mutations[types.EXPORT_AS_TYPESCRIPT](state, "on"); |
| 55 | +// expect(state.exportAsTypescript).toEqual("on"); |
| 56 | +// mutations[types.EXPORT_AS_TYPESCRIPT](state, "off"); |
| 57 | +// expect(state.exportAsTypescript).toEqual("off"); |
| 58 | +// }); |
| 59 | + |
| 60 | +// //tests that the tutorial toggle successfully updates state to true/false |
| 61 | +// test('"[types.toggleTutorial]" action to commit TOGGLE_TUTORIAL', () => { |
| 62 | +// const commit = jest.fn(); |
| 63 | +// actions[types.toggleTutorial]({ state, commit }); |
| 64 | +// expect(commit).toHaveBeenCalledWith(types.TOGGLE_TUTORIAL); |
| 65 | +// }); |
| 66 | + |
| 67 | +// test('"[types.TOGGLE_TUTORIAL]" to mutate state true/false', () => { |
| 68 | +// mutations[types.TOGGLE_TUTORIAL](state); |
| 69 | +// expect(state.showTutorial).toBe(false); |
| 70 | +// mutations[types.TOGGLE_TUTORIAL](state); |
| 71 | +// expect(state.showTutorial).toBe(true); |
| 72 | +// }); |
| 73 | +// }); |
0 commit comments