Skip to content

Commit 3cfb55c

Browse files
committed
resolving merge conflicts
2 parents d7bc835 + abde05f commit 3cfb55c

File tree

4 files changed

+67
-55
lines changed

4 files changed

+67
-55
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
@@ -204,6 +204,14 @@ const mutations = {
204204
},
205205
[types.ADD_TO_COMPONENT_STATE]: (state, payload) => {
206206
state.componentMap[state.activeComponent].componentState.push(payload)
207+
208+
},
209+
[types.ADD_USER_ACTION]: (state, payload) => {
210+
if (typeof(payload)==='string') state.userActions.push(payload);
211+
},
212+
[types.ADD_TO_USER_STORE]: (state, payload) => {
213+
const key = Object.keys(payload);
214+
state.userStore[key] = payload[key];
207215
}
208216
}
209217

src/store/types.js

Lines changed: 4 additions & 0 deletions
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 ADD_TO_COMPONENT_ACTIONS = 'ADD_TO_COMPONENT_ACTIONS'
4545
export const ADD_TO_COMPONENT_STATE = 'ADD_TO_COMPONENT_STATE'
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'
@@ -77,3 +79,5 @@ export const updateOpenModal = 'updateOpenModal'
7779
export const parentSelected = 'parentSelected'
7880
export const deleteRoute = 'deleteRoute'
7981
export const deleteComponent = 'deleteComponent'
82+
export const addUserAction = 'addUserAction'
83+
export const addToUserStore = 'addToUserStore'

test/jest/__tests__/App.spec.js

Lines changed: 51 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -2,14 +2,18 @@
22
/**
33
* @jest-environment jsdom
44
*/
5-
5+
import mutations from '../../../src/store/mutations';
66
import { mount, createLocalVue, shallowMount } from '@vue/test-utils'
7+
import Vuex from 'vuex';
78
import QBUTTON from './demo/QBtn-demo.vue'
89
import * as All from 'quasar'
9-
import mutations from '../../../src/store/mutations'
1010
// import langEn from 'quasar/lang/en-us' // change to any language you wish! => this breaks wallaby :(
1111
const { Quasar, date } = All
1212

13+
//const localVue = createLocalVue()
14+
15+
// localVue.use(Vuex)
16+
1317
const components = Object.keys(All).reduce((object, key) => {
1418
const val = All[key]
1519
if (val && val.component && val.component.name != null) {
@@ -18,15 +22,6 @@ const components = Object.keys(All).reduce((object, key) => {
1822
return object
1923
}, {})
2024

21-
describe('Dummy test', () => {
22-
const localVue = createLocalVue()
23-
localVue.use(Quasar, { components })
24-
const testValue = false;
25-
it('does this produce the correct result', () => {
26-
expect(testValue).toBe(false)
27-
})
28-
})
29-
3025
describe('Adding actions and state to components', () => {
3126
let state;
3227
beforeEach(() => {
@@ -57,45 +52,50 @@ describe('Adding actions and state to components', () => {
5752
})
5853
})
5954

60-
// describe('Mount Quasar', () => {
61-
// const localVue = createLocalVue()
62-
// localVue.use(Quasar, { components }) // , lang: langEn
63-
64-
// const wrapper = mount(QBUTTON, {
65-
// localVue
66-
// })
67-
// const vm = wrapper.vm
68-
69-
// it('passes the sanity check and creates a wrapper', () => {
70-
// expect(wrapper.isVueInstance()).toBe(true)
71-
// })
72-
73-
// it('has a created hook', () => {
74-
// expect(typeof vm.increment).toBe('function')
75-
// })
76-
77-
// it('accesses the shallowMount', () => {
78-
// expect(vm.$el.textContent).toContain('rocket muffin')
79-
// expect(wrapper.text()).toContain('rocket muffin') // easier
80-
// expect(wrapper.find('p').text()).toContain('rocket muffin')
81-
// })
82-
83-
// it('sets the correct default data', () => {
84-
// expect(typeof vm.counter).toBe('number')
85-
// const defaultData2 = QBUTTON.data()
86-
// expect(defaultData2.counter).toBe(0)
87-
// })
55+
describe('userActions mutation', () => {
56+
let actions;
57+
let store;
58+
beforeEach(() => {
59+
store = {
60+
userActions: []
61+
}
62+
})
63+
it ('should push user defined action to end of userActions array', () => {
64+
mutations.ADD_USER_ACTION(store, 'actionnnn')
65+
expect(store.userActions[store.userActions.length-1]).toBe('actionnnn');
66+
})
67+
it ('should only push to array if payload is of type string', () => {
68+
mutations.ADD_USER_ACTION(store, 66)
69+
expect(store.userActions).toStrictEqual([])
70+
})
71+
});
8872

89-
// it('correctly updates data when button is pressed', () => {
90-
// const button = wrapper.find('button')
91-
// button.trigger('click')
92-
// expect(vm.counter).toBe(1)
93-
// })
73+
describe('userStore mutation', () => {
74+
let actions;
75+
let store;
76+
store = {
77+
userStore : {}
78+
}
79+
it ('should be able to update store with a key defined by the user and a value of type object', () => {
80+
mutations.ADD_TO_USER_STORE(store, {'dummyKey': {}})
81+
// console.log('store.userStore.dummyKey', store.userStore.dummyKey);
82+
expect(store.userStore.dummyKey).toStrictEqual({})
83+
})
84+
it ('should update user store with a key value pair with value strictly equal to empty array', () => {
85+
mutations.ADD_TO_USER_STORE(store, {'dummyKey': []})
86+
expect(store.userStore.dummyKey).toStrictEqual([]);
87+
})
88+
it ('should be able to store booleans in the store as the key', () => {
89+
mutations.ADD_TO_USER_STORE(store, {boolean: true})
90+
expect (store.userStore.boolean).toBe(true)
91+
})
92+
it ('should add to userStore a key with a value of type number', () => {
93+
mutations.ADD_TO_USER_STORE(store, { number:696 })
94+
expect (store.userStore.number).toBe(696)
95+
})
9496

95-
// it('formats a date without throwing exception', () => {
96-
// // test will automatically fail if an exception is thrown
97-
// // MMMM and MMM require that a language is 'installed' in Quasar
98-
// let formattedString = date.formatDate(Date.now(), 'YYYY MMMM MMM DD')
99-
// console.log('formattedString', formattedString)
100-
// })
101-
// })
97+
it ('should work with strings too', () => {
98+
mutations.ADD_TO_USER_STORE(store, { string: 'string'})
99+
expect(store.userStore.string).toBe('string')
100+
})
101+
});

0 commit comments

Comments
 (0)