@@ -11,6 +11,7 @@ import { anyString, anything, instance, mock, verify, when } from 'ts-mockito';
11
11
import { Basket } from 'ish-core/models/basket/basket.model' ;
12
12
import { BasketService } from 'ish-core/services/basket/basket.service' ;
13
13
import { CoreStoreModule } from 'ish-core/store/core/core-store.module' ;
14
+ import { loadServerConfigSuccess } from 'ish-core/store/core/server-config' ;
14
15
import { CustomerStoreModule } from 'ish-core/store/customer/customer-store.module' ;
15
16
import { resetOrderErrors } from 'ish-core/store/customer/orders' ;
16
17
import { ApiTokenService } from 'ish-core/utils/api-token/api-token.service' ;
@@ -62,7 +63,7 @@ describe('Basket Effects', () => {
62
63
TestBed . configureTestingModule ( {
63
64
declarations : [ DummyComponent ] ,
64
65
imports : [
65
- CoreStoreModule . forTesting ( [ 'router' ] ) ,
66
+ CoreStoreModule . forTesting ( [ 'router' , 'serverConfig' , 'configuration' ] ) ,
66
67
CustomerStoreModule . forTesting ( 'user' , 'basket' ) ,
67
68
RouterTestingModule . withRoutes ( [ { path : '**' , component : DummyComponent } ] ) ,
68
69
] ,
@@ -194,6 +195,37 @@ describe('Basket Effects', () => {
194
195
} ) ;
195
196
} ) ;
196
197
198
+ describe ( 'recalculateBasketAfterCurrencyChange$' , ( ) => {
199
+ beforeEach ( ( ) => {
200
+ store$ . dispatch (
201
+ loadServerConfigSuccess ( {
202
+ config : {
203
+ general : {
204
+ defaultLocale : 'de_DE' ,
205
+ defaultCurrency : 'EUR' ,
206
+ locales : [ 'en_US' , 'de_DE' , 'fr_BE' , 'nl_BE' ] ,
207
+ currencies : [ 'USD' , 'EUR' ] ,
208
+ } ,
209
+ } ,
210
+ } )
211
+ ) ;
212
+ } ) ;
213
+
214
+ it ( 'should trigger a basket recalculation if the basket currency differs from current currency' , done => {
215
+ const id = 'BID' ;
216
+
217
+ actions$ = of ( loadBasketSuccess ( { basket : { id, purchaseCurrency : 'USD' } as Basket } ) ) ;
218
+
219
+ effects . recalculateBasketAfterCurrencyChange$ . subscribe ( action => {
220
+ expect ( action ) . toMatchInlineSnapshot ( `
221
+ [Basket Internal] Update Basket:
222
+ update: {"calculated":true}
223
+ ` ) ;
224
+ done ( ) ;
225
+ } ) ;
226
+ } ) ;
227
+ } ) ;
228
+
197
229
describe ( 'createBasket$' , ( ) => {
198
230
beforeEach ( ( ) => {
199
231
when ( basketServiceMock . createBasket ( ) ) . thenCall ( ( ) => of ( { id : 'BID' } as Basket ) ) ;
0 commit comments