@@ -138,7 +138,7 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
138
138
expect ( fixture . nativeElement ) . toHaveText ( 'hello' ) ;
139
139
} ) ) ;
140
140
141
- describe ( 'else' , ( ) => {
141
+ describe ( 'then/ else templates ' , ( ) => {
142
142
it ( 'should support else' , async ( ( ) => {
143
143
const template = '<span *ngIf="booleanCondition; else elseBlock">TRUE</span>' +
144
144
'<ng-template #elseBlock>FALSE</ng-template>' ;
@@ -169,6 +169,37 @@ import {expect} from '@angular/platform-browser/testing/src/matchers';
169
169
expect ( fixture . nativeElement ) . toHaveText ( 'ELSE' ) ;
170
170
} ) ) ;
171
171
172
+ it ( 'should support removing the then/else templates' , ( ) => {
173
+ const template = `<span *ngIf="booleanCondition;
174
+ then nestedBooleanCondition ? tplRef : null;
175
+ else nestedBooleanCondition ? tplRef : null"></span>
176
+ <ng-template #tplRef>Template</ng-template>` ;
177
+
178
+ fixture = createTestComponent ( template ) ;
179
+ const comp = fixture . componentInstance ;
180
+ // then template
181
+ comp . booleanCondition = true ;
182
+
183
+ comp . nestedBooleanCondition = true ;
184
+ fixture . detectChanges ( ) ;
185
+ expect ( fixture . nativeElement ) . toHaveText ( 'Template' ) ;
186
+
187
+ comp . nestedBooleanCondition = false ;
188
+ fixture . detectChanges ( ) ;
189
+ expect ( fixture . nativeElement ) . toHaveText ( '' ) ;
190
+
191
+ // else template
192
+ comp . booleanCondition = true ;
193
+
194
+ comp . nestedBooleanCondition = true ;
195
+ fixture . detectChanges ( ) ;
196
+ expect ( fixture . nativeElement ) . toHaveText ( 'Template' ) ;
197
+
198
+ comp . nestedBooleanCondition = false ;
199
+ fixture . detectChanges ( ) ;
200
+ expect ( fixture . nativeElement ) . toHaveText ( '' ) ;
201
+ } ) ;
202
+
172
203
it ( 'should support dynamic else' , async ( ( ) => {
173
204
const template =
174
205
'<span *ngIf="booleanCondition; else nestedBooleanCondition ? b1 : b2">TRUE</span>' +
0 commit comments