Skip to content

Commit 6181127

Browse files
Dean OhashiDean Ohashi
authored andcommitted
resolved conflicts
2 parents 7288023 + abde05f commit 6181127

File tree

4 files changed

+66
-8
lines changed

4 files changed

+66
-8
lines changed

package-lock.json

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

src/store/mutations.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,14 @@ const mutations = {
207207
[types.REMOVE_ACTION_FROM_COMPONENT]: (state, payload) => {
208208
let index = state.componentMap[state.activeComponent].mapActions.indexOf(payload)
209209
state.componentMap[state.activeComponent].mapActions.splice(index, 1)
210+
211+
},
212+
[types.ADD_USER_ACTION]: (state, payload) => {
213+
if (typeof(payload)==='string') state.userActions.push(payload);
214+
},
215+
[types.ADD_TO_USER_STORE]: (state, payload) => {
216+
const key = Object.keys(payload);
217+
state.userStore[key] = payload[key];
210218
}
211219
}
212220

src/store/types.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,8 @@ export const DELETE_ROUTE = 'DELETE_ROUTE'
4343
export const DELETE_COMPONENT = 'DELETE_COMPONENT'
4444
export const DELETE_USER_ACTIONS = 'DELETE_USER_ACTIONS'
4545
export const REMOVE_ACTION_FROM_COMPONENT = 'REMOVE_ACTION_FROM_COMPONENT'
46+
export const ADD_USER_ACTION = 'ADD_USER_ACTION'
47+
export const ADD_TO_USER_STORE = 'ADD_TO_USER_STORE'
4648

4749
// Actions
4850
export const registerComponent = 'registerComponent'
@@ -79,4 +81,6 @@ export const deleteRoute = 'deleteRoute'
7981
export const deleteComponent = 'deleteComponent'
8082

8183
export const deleteUserActions = 'deleteUserActions'
82-
export const removeActionFromComponent = 'removeActionFromComponent'
84+
export const removeActionFromComponent = 'removeActionFromComponent'
85+
export const addUserAction = 'addUserAction'
86+
export const addToUserStore = 'addToUserStore'

test/jest/__tests__/App.spec.js

Lines changed: 49 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,12 +2,10 @@
22
/**
33
* @jest-environment jsdom
44
*/
5-
5+
import mutations from '../../../src/store/mutations';
66
import { mount, createLocalVue, shallowMount } from '@vue/test-utils'
77
import * as All from 'quasar'
88
const { Quasar, date } = All
9-
10-
import mutations from '../../../src/store/mutations'
119
import actions from '../../../src/store/actions'
1210

1311
describe('Test mutations + actions to remove action from component and userActions', () => {
@@ -43,3 +41,51 @@ describe('Test mutations + actions to remove action from component and userActio
4341
// expect(state.userActions.length).toBe(0)
4442
// })
4543
})
44+
45+
describe('userActions mutation', () => {
46+
let actions;
47+
let store;
48+
beforeEach(() => {
49+
store = {
50+
userActions: []
51+
}
52+
})
53+
it ('should push user defined action to end of userActions array', () => {
54+
mutations.ADD_USER_ACTION(store, 'actionnnn')
55+
expect(store.userActions[store.userActions.length-1]).toBe('actionnnn');
56+
})
57+
it ('should only push to array if payload is of type string', () => {
58+
mutations.ADD_USER_ACTION(store, 66)
59+
expect(store.userActions).toStrictEqual([])
60+
})
61+
});
62+
63+
describe('userStore mutation', () => {
64+
let actions;
65+
let store;
66+
store = {
67+
userStore : {}
68+
}
69+
it ('should be able to update store with a key defined by the user and a value of type object', () => {
70+
mutations.ADD_TO_USER_STORE(store, {'dummyKey': {}})
71+
// console.log('store.userStore.dummyKey', store.userStore.dummyKey);
72+
expect(store.userStore.dummyKey).toStrictEqual({})
73+
})
74+
it ('should update user store with a key value pair with value strictly equal to empty array', () => {
75+
mutations.ADD_TO_USER_STORE(store, {'dummyKey': []})
76+
expect(store.userStore.dummyKey).toStrictEqual([]);
77+
})
78+
it ('should be able to store booleans in the store as the key', () => {
79+
mutations.ADD_TO_USER_STORE(store, {boolean: true})
80+
expect (store.userStore.boolean).toBe(true)
81+
})
82+
it ('should add to userStore a key with a value of type number', () => {
83+
mutations.ADD_TO_USER_STORE(store, { number:696 })
84+
expect (store.userStore.number).toBe(696)
85+
})
86+
87+
it ('should work with strings too', () => {
88+
mutations.ADD_TO_USER_STORE(store, { string: 'string'})
89+
expect(store.userStore.string).toBe('string')
90+
})
91+
});

0 commit comments

Comments
 (0)