@@ -4,7 +4,6 @@ import {MockBackend, MockConnection} from "@angular/http/testing";
4
4
import {
5
5
TranslateService ,
6
6
MissingTranslationHandler ,
7
- MissingTranslationHandlerParams ,
8
7
TranslateLoader ,
9
8
TranslateStaticLoader ,
10
9
LangChangeEvent ,
@@ -311,23 +310,23 @@ describe('MissingTranslationHandler', () => {
311
310
let missingTranslationHandler : MissingTranslationHandler ;
312
311
313
312
class Missing implements MissingTranslationHandler {
314
- handle ( params : MissingTranslationHandlerParams ) {
313
+ handle ( key : string ) {
315
314
return "handled" ;
316
315
}
317
316
}
318
317
319
318
class MissingObs implements MissingTranslationHandler {
320
- handle ( params : MissingTranslationHandlerParams ) : Observable < any > {
321
- return Observable . of ( `handled: ${ params . key } ` ) ;
319
+ handle ( key : string ) : Observable < any > {
320
+ return Observable . of ( `handled: ${ key } ` ) ;
322
321
}
323
322
}
324
323
325
324
let prepare = ( ( handlerClass : Function ) => {
326
325
TestBed . configureTestingModule ( {
327
326
imports : [ HttpModule , TranslateModule . forRoot ( ) ] ,
328
327
providers : [
329
- { provide : MissingTranslationHandler , useClass : handlerClass } ,
330
- { provide : XHRBackend , useClass : MockBackend }
328
+ { provide : MissingTranslationHandler , useClass : handlerClass } ,
329
+ { provide : XHRBackend , useClass : MockBackend }
331
330
]
332
331
} ) ;
333
332
injector = getTestBed ( ) ;
@@ -352,40 +351,7 @@ describe('MissingTranslationHandler', () => {
352
351
spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
353
352
354
353
translate . get ( 'nonExistingKey' ) . subscribe ( ( res : string ) => {
355
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { key : 'nonExistingKey' } ) ) ;
356
- //test that the instance of the last called argument is string
357
- expect ( res ) . toEqual ( 'handled' ) ;
358
- } ) ;
359
-
360
- // mock response after the xhr request, otherwise it will be undefined
361
- mockBackendResponse ( connection , '{"TEST": "This is a test"}' ) ;
362
- } ) ;
363
-
364
- it ( 'should propagate interpolation params when the key does not exist' , ( ) => {
365
- prepare ( Missing ) ;
366
- translate . use ( 'en' ) ;
367
- spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
368
- let interpolateParams = { some : 'params' } ;
369
-
370
- translate . get ( 'nonExistingKey' , interpolateParams ) . subscribe ( ( res : string ) => {
371
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { interpolateParams : interpolateParams } ) ) ;
372
- //test that the instance of the last called argument is string
373
- expect ( res ) . toEqual ( 'handled' ) ;
374
- } ) ;
375
-
376
- // mock response after the xhr request, otherwise it will be undefined
377
- mockBackendResponse ( connection , '{"TEST": "This is a test"}' ) ;
378
- } ) ;
379
-
380
- it ( 'should propagate TranslationService params when the key does not exist' , ( ) => {
381
- prepare ( Missing ) ;
382
- translate . use ( 'en' ) ;
383
- spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
384
- let interpolateParams = { some : 'params' } ;
385
-
386
- translate . get ( 'nonExistingKey' , interpolateParams ) . subscribe ( ( res : string ) => {
387
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { translateService : translate } ) ) ;
388
- //test that the instance of the last called argument is string
354
+ expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( 'nonExistingKey' ) ;
389
355
expect ( res ) . toEqual ( 'handled' ) ;
390
356
} ) ;
391
357
@@ -395,7 +361,7 @@ describe('MissingTranslationHandler', () => {
395
361
396
362
it ( 'should return the key when using MissingTranslationHandler & the handler returns nothing' , ( ) => {
397
363
class MissingUndef implements MissingTranslationHandler {
398
- handle ( params : MissingTranslationHandlerParams ) {
364
+ handle ( key : string ) {
399
365
}
400
366
}
401
367
@@ -404,7 +370,7 @@ describe('MissingTranslationHandler', () => {
404
370
spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
405
371
406
372
translate . get ( 'nonExistingKey' ) . subscribe ( ( res : string ) => {
407
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { key : 'nonExistingKey' } ) ) ;
373
+ expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( 'nonExistingKey' ) ;
408
374
expect ( res ) . toEqual ( 'nonExistingKey' ) ;
409
375
} ) ;
410
376
@@ -431,7 +397,7 @@ describe('MissingTranslationHandler', () => {
431
397
spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
432
398
433
399
expect ( translate . instant ( 'nonExistingKey' ) ) . toEqual ( 'handled' ) ;
434
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { key : 'nonExistingKey' } ) ) ;
400
+ expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( 'nonExistingKey' ) ;
435
401
} ) ;
436
402
437
403
it ( 'should wait for the MissingTranslationHandler when it returns an observable & we use get' , ( ) => {
@@ -440,7 +406,7 @@ describe('MissingTranslationHandler', () => {
440
406
spyOn ( missingTranslationHandler , 'handle' ) . and . callThrough ( ) ;
441
407
442
408
translate . get ( 'nonExistingKey' ) . subscribe ( ( res : string ) => {
443
- expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( jasmine . objectContaining ( { key : 'nonExistingKey' } ) ) ;
409
+ expect ( missingTranslationHandler . handle ) . toHaveBeenCalledWith ( 'nonExistingKey' ) ;
444
410
expect ( res ) . toEqual ( 'handled: nonExistingKey' ) ;
445
411
} ) ;
446
412
0 commit comments