1
1
import vueUnitHelper from 'vue-unit-helper' ;
2
2
import LangPicker from '!!vue-loader?inject!@/locale/cd-lang-picker' ;
3
3
import { expect } from 'chai' ;
4
+ import Vuex from 'vuex' ;
4
5
5
6
describe ( 'Lang Picker' , ( ) => {
6
7
let CookieMock ;
7
8
let LocaleServiceMock ;
8
9
let MomentMock ;
9
10
let LangPickerWithMocks ;
10
- let StoreMock ;
11
+ const StoreMock = new Vuex . Store ( )
11
12
12
13
beforeEach ( ( ) => {
13
14
CookieMock = {
@@ -26,9 +27,7 @@ describe('Lang Picker', () => {
26
27
moment : MomentMock ,
27
28
} ) ;
28
29
29
- StoreMock = {
30
- dispatch : sinon . stub ( ) ,
31
- } ;
30
+ StoreMock . dispatch = sinon . stub ( ) ;
32
31
} ) ;
33
32
34
33
afterEach ( ( ) => {
@@ -96,7 +95,7 @@ describe('Lang Picker', () => {
96
95
foo : 'foo' ,
97
96
} ) ;
98
97
expect ( vm . $i18n . locale ) . to . equal ( 'es_ES' ) ;
99
- expect ( StoreMock . dispatch . calledOnce ) . to . eq ( true ) ;
98
+ expect ( StoreMock . dispatch ) . to . have . been . calledWith ( 'updateChosenLanguageConfig' ) ;
100
99
done ( ) ;
101
100
} ) ;
102
101
} ) ;
@@ -130,7 +129,7 @@ describe('Lang Picker', () => {
130
129
131
130
// ASSERT
132
131
expect ( vm . lang ) . to . equal ( 'es_ES' ) ;
133
- expect ( StoreMock . dispatch . calledOnce ) . to . eq ( true ) ;
132
+ expect ( StoreMock . dispatch ) . to . have . been . calledWith ( 'updateChosenLanguageConfig' ) ;
134
133
} ) ;
135
134
136
135
it ( 'should set lang to the browser locale if no cookie, and locale matches an available one' , async ( ) => {
@@ -146,7 +145,7 @@ describe('Lang Picker', () => {
146
145
147
146
// ASSERT
148
147
expect ( vm . lang ) . to . equal ( 'it_IT' ) ;
149
- expect ( StoreMock . dispatch . calledOnce ) . to . eq ( true ) ;
148
+ expect ( StoreMock . dispatch ) . to . have . been . calledWith ( 'updateChosenLanguageConfig' ) ;
150
149
} ) ;
151
150
152
151
it ( 'should set lang to en_US if no cookie and browser locale doesnt match available lang' , async ( ) => {
@@ -162,7 +161,7 @@ describe('Lang Picker', () => {
162
161
163
162
// ASSERT
164
163
expect ( vm . lang ) . to . equal ( 'en_US' ) ;
165
- expect ( StoreMock . dispatch . calledOnce ) . to . eq ( true ) ;
164
+ expect ( StoreMock . dispatch ) . to . have . been . calledWith ( 'updateChosenLanguageConfig' ) ;
166
165
} ) ;
167
166
} ) ;
168
167
} ) ;
0 commit comments