|
2 | 2 | /** |
3 | 3 | * @jest-environment jsdom |
4 | 4 | */ |
5 | | - |
| 5 | +import mutations from '../../../src/store/mutations'; |
6 | 6 | import { mount, createLocalVue, shallowMount } from '@vue/test-utils' |
7 | 7 | import * as All from 'quasar' |
8 | 8 | const { Quasar, date } = All |
9 | | - |
10 | | -import mutations from '../../../src/store/mutations' |
11 | 9 | import actions from '../../../src/store/actions' |
12 | 10 |
|
13 | 11 | 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 |
43 | 41 | // expect(state.userActions.length).toBe(0) |
44 | 42 | // }) |
45 | 43 | }) |
| 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