Skip to content

Commit c9cf80b

Browse files
Ji KimJi Kim
authored andcommitted
Merge branch 'ji-typescript' into typescript
2 parents 4918691 + 10ac56a commit c9cf80b

File tree

3 files changed

+119
-24
lines changed

3 files changed

+119
-24
lines changed

package-lock.json

Lines changed: 60 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,7 @@
6969
},
7070
"devDependencies": {
7171
"@babel/eslint-parser": "^7.17.0",
72+
"@pinia/testing": "^0.0.14",
7273
"@quasar/app": "^3.3.3",
7374
"@quasar/quasar-app-extension-testing-unit-jest": "^3.0.0-alpha.7",
7475
"@vue/devtools": "^6.0.12",
Lines changed: 58 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,39 +1,73 @@
11
import { mount, shallowMount } from "@vue/test-utils";
22
import { createApp } from "vue";
3+
import { createTestingPinia } from "@pinia/testing";
34
import * as All from "quasar";
45
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";
107

8+
const store = useStore();
119
//testing that export as typescript on/off, showTutorial, all update properly
1210
describe("Test for exportAsTypescript flag to flip when mutation committed", () => {
1311
const App = {};
1412
const app = createApp(App);
15-
app.use(Quasar, Vuex);
16-
const state = { ...store };
13+
app.use(Quasar);
1714

1815
//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");
2421
});
2522

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);
3828
});
3929
});
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

Comments
 (0)