@@ -40,6 +40,23 @@ class FakeChangeDetectorRef extends ChangeDetectorRef {
40
40
}
41
41
}
42
42
43
+ @Injectable ( )
44
+ @Component ( {
45
+ selector : 'lib-hmx-app' ,
46
+ standalone : true ,
47
+ imports : [ TranslatePipe ] ,
48
+ changeDetection : ChangeDetectionStrategy . OnPush ,
49
+ template : `{{'default' | translate}}`
50
+ } )
51
+ class AppTranslationIdDefaultComponent {
52
+ viewContainerRef : ViewContainerRef ;
53
+
54
+ constructor ( viewContainerRef : ViewContainerRef ) {
55
+ this . viewContainerRef = viewContainerRef ;
56
+ }
57
+ }
58
+
59
+
43
60
@Injectable ( )
44
61
@Component ( {
45
62
selector : 'lib-hmx-app' ,
@@ -123,6 +140,15 @@ describe('TranslatePipe (standalone)', () => {
123
140
expect ( translatePipe . transform ( 'TEST' ) ) . toEqual ( "This is a test" ) ;
124
141
} ) ;
125
142
143
+ it ( "should translate 'default'" , ( ) =>
144
+ {
145
+ prepare ( ) ;
146
+ translate . setTranslation ( "en" , { "default" : "This is the default message" } ) ;
147
+ translate . use ( "en" ) ;
148
+
149
+ expect ( translatePipe . transform ( "default" ) ) . toEqual ( "This is the default message" ) ;
150
+ } ) ;
151
+
126
152
it ( 'should call markForChanges when it translates a string' , ( ) => {
127
153
prepare ( ) ;
128
154
translate . setTranslation ( 'en' , { "TEST" : "This is a test" } ) ;
@@ -374,5 +400,20 @@ describe('TranslatePipe (standalone)', () => {
374
400
fixture . detectChanges ( ) ;
375
401
expect ( fixture . debugElement . nativeElement . innerHTML ) . toEqual ( "This is a test" ) ;
376
402
} ) ;
403
+
404
+
405
+ it ( "translate text with 'default' message id" , ( ) => {
406
+ prepare ( ) ;
407
+
408
+ const fixture = TestBed . createComponent ( AppTranslationIdDefaultComponent ) ;
409
+
410
+ translate . setTranslation ( "en" , { "default" : "This is some default text" } ) ;
411
+
412
+ fixture . detectChanges ( ) ;
413
+ expect ( fixture . debugElement . nativeElement . innerHTML ) . toEqual ( "default" ) ;
414
+ translate . setDefaultLang ( 'en' ) ;
415
+ fixture . detectChanges ( ) ;
416
+ expect ( fixture . debugElement . nativeElement . innerHTML ) . toEqual ( "This is some default text" ) ;
417
+ } ) ;
377
418
} ) ;
378
419
} ) ;
0 commit comments