Skip to content

Commit d25e619

Browse files
committed
Starting tests for copy and paste, not previously implemented. Refactored route testing slightly.
1 parent 8f47f01 commit d25e619

File tree

2 files changed

+30
-3
lines changed

2 files changed

+30
-3
lines changed

test/jest/__tests__/copyPaste.spec.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { mount, shallowMount } from "@vue/test-utils";
2+
import { createApp } from "vue";
3+
import * as All from "quasar";
4+
const { Quasar, date } = All;
5+
import actions from "../../../src/store/actions";
6+
import mutations from "../../../src/store/mutations";
7+
import * as types from "../../../src/store/types";
8+
import Vuex from "vuex";
9+
import store from "../../../src/store/state/index";
10+
11+
describe("Tests for copy and pasting", () => {
12+
const App = {}
13+
const app = createApp(App);
14+
app.use(Quasar, Vuex);
15+
const state = { ...store }
16+
17+
test('"[types.copyActiveComponent]" action to commit COPY_ACTIVE_COMPONENT', () => {
18+
const commit = jest.fn();
19+
actions[types.copyActiveComponent]({ commit }, {});
20+
expect(commit).toHaveBeenCalledWith(types.COPY_ACTIVE_COMPONENT, {});
21+
});
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, {});
26+
});
27+
28+
29+
});

test/jest/__tests__/routeTests.spec.js

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,16 +93,14 @@ describe("Test Suite for route actions and related mutations", () => {
9393
test('"[types.ADD_COMPONENT_TO_COMPONENT_CHILDREN]" mutation to add created route as one of Apps children', () => {
9494
let component = 'App';
9595
let value = state.componentMap[state.activeRoute].componentName;
96-
// console.log('pre: ', state.componentMap[component].children);
9796
expect(state.componentMap[component].children.length).toBe(1);
9897
mutations[types.ADD_COMPONENT_TO_COMPONENT_CHILDREN](state, {component, value});
99-
// console.log('post: ', state.componentMap[component].children);
10098
expect(state.componentMap[component].children.length).toBe(2);
10199
expect(state.componentMap[component].children[state.componentMap[component].children.length-1]).toBe(value);
102100

103101
});
104102

105-
test('"[types.DELETE_ROUTE]" mutation to ---', () => {
103+
test('"[types.DELETE_ROUTE]" mutation to update state by removing a route', () => {
106104
const payload = 'testRoute';
107105
let flag = false;
108106
// pre mutation tests

0 commit comments

Comments
 (0)