22/**
33 * @jest -environment jsdom
44 */
5- import actions from '../../store/actions ' ;
5+ import mutations from '../../../src/ store/mutations ' ;
66import { mount , createLocalVue , shallowMount } from '@vue/test-utils'
7+ import Vuex from 'vuex' ;
78import QBUTTON from './demo/QBtn-demo.vue'
89import * as All from 'quasar'
10+
911// import langEn from 'quasar/lang/en-us' // change to any language you wish! => this breaks wallaby :(
1012const { Quasar, date } = All
1113
12- const localVue = createLocalVue ( )
14+ // const localVue = createLocalVue()
1315
14- localVue . use ( Vuex )
16+ // localVue.use(Vuex)
1517
1618const components = Object . keys ( All ) . reduce ( ( object , key ) => {
1719 const val = All [ key ]
@@ -64,23 +66,50 @@ describe('Mount Quasar', () => {
6466 })
6567})
6668*/
67- describe ( 'actions ' , ( ) => {
69+ describe ( 'userActions mutation ' , ( ) => {
6870 let actions ;
6971 let store ;
7072 beforeEach ( ( ) => {
71- const dummyFunction = jest . fn ( ( ) => 'hello' )
72- actions = {
73- userActionInput : dummyFunction ,
74- userStore : dummyFunction
73+ store = {
74+ userActions : [ ]
7575 }
76- store = new Vuex . Store ( {
77- actions
78- } )
7976 } )
77+ it ( 'should push user defined action to end of userActions array' , ( ) => {
78+ mutations . ADD_USER_ACTION ( store , 'actionnnn' )
79+ expect ( store . userActions [ store . userActions . length - 1 ] ) . toBe ( 'actionnnn' ) ;
80+ } )
81+ it ( 'should only push to array if payload is of type string' , ( ) => {
82+ mutations . ADD_USER_ACTION ( store , 66 )
83+ expect ( store . userActions ) . toStrictEqual ( [ ] )
84+ } )
85+ } ) ;
8086
81- it ( 'should take in a string and output a string into userActions array' , ( ) => {
82- const wrapper = shallowMount ( actions , { store, localVue } )
83-
87+ describe ( 'userStore mutation' , ( ) => {
88+ let actions ;
89+ let store ;
90+ store = {
91+ userStore : { }
92+ }
93+ it ( 'should be able to update store with a key defined by the user and a value of type object' , ( ) => {
94+ mutations . ADD_TO_USER_STORE ( store , { 'dummyKey' : { } } )
95+ // console.log('store.userStore.dummyKey', store.userStore.dummyKey);
96+ expect ( store . userStore . dummyKey ) . toStrictEqual ( { } )
97+ } )
98+ it ( 'should update user store with a key value pair with value strictly equal to empty array' , ( ) => {
99+ mutations . ADD_TO_USER_STORE ( store , { 'dummyKey' : [ ] } )
100+ expect ( store . userStore . dummyKey ) . toStrictEqual ( [ ] ) ;
101+ } )
102+ it ( 'should be able to store booleans in the store as the key' , ( ) => {
103+ mutations . ADD_TO_USER_STORE ( store , { boolean : true } )
104+ expect ( store . userStore . boolean ) . toBe ( true )
105+ } )
106+ it ( 'should add to userStore a key with a value of type number' , ( ) => {
107+ mutations . ADD_TO_USER_STORE ( store , { number :696 } )
108+ expect ( store . userStore . number ) . toBe ( 696 )
84109 } )
85110
111+ it ( 'should work with strings too' , ( ) => {
112+ mutations . ADD_TO_USER_STORE ( store , { string : 'string' } )
113+ expect ( store . userStore . string ) . toBe ( 'string' )
114+ } )
86115} ) ;
0 commit comments