@@ -146,6 +146,87 @@ function declareTests({useJit}: {useJit: boolean}) {
146
146
expect ( kf [ 1 ] ) . toEqual ( [ 1 , { 'background' : 'blue' } ] ) ;
147
147
} ) ) ;
148
148
149
+ describe ( 'animation aliases' , ( ) => {
150
+ it ( 'should animate the ":enter" animation alias as "void => *"' , fakeAsync ( ( ) => {
151
+ TestBed . overrideComponent ( DummyIfCmp , {
152
+ set : {
153
+ template : `
154
+ <div *ngIf="exp" [@myAnimation]="exp"></div>
155
+ ` ,
156
+ animations : [ trigger (
157
+ 'myAnimation' ,
158
+ [ transition (
159
+ ':enter' ,
160
+ [ style ( { 'opacity' : 0 } ) , animate ( '500ms' , style ( { opacity : 1 } ) ) ] ) ] ) ]
161
+ }
162
+ } ) ;
163
+
164
+ const driver = TestBed . get ( AnimationDriver ) as MockAnimationDriver ;
165
+ let fixture = TestBed . createComponent ( DummyIfCmp ) ;
166
+ var cmp = fixture . componentInstance ;
167
+ cmp . exp = true ;
168
+ fixture . detectChanges ( ) ;
169
+
170
+ expect ( driver . log . length ) . toEqual ( 1 ) ;
171
+
172
+ var animation = driver . log [ 0 ] ;
173
+ expect ( animation [ 'duration' ] ) . toEqual ( 500 ) ;
174
+ } ) ) ;
175
+
176
+ it ( 'should animate the ":leave" animation alias as "* => void"' , fakeAsync ( ( ) => {
177
+ TestBed . overrideComponent ( DummyIfCmp , {
178
+ set : {
179
+ template : `
180
+ <div *ngIf="exp" [@myAnimation]="exp"></div>
181
+ ` ,
182
+ animations : [ trigger (
183
+ 'myAnimation' ,
184
+ [ transition ( ':leave' , [ animate ( '999ms' , style ( { opacity : 0 } ) ) ] ) ] ) ]
185
+ }
186
+ } ) ;
187
+
188
+ const driver = TestBed . get ( AnimationDriver ) as MockAnimationDriver ;
189
+ let fixture = TestBed . createComponent ( DummyIfCmp ) ;
190
+ var cmp = fixture . componentInstance ;
191
+ cmp . exp = true ;
192
+ fixture . detectChanges ( ) ;
193
+
194
+ expect ( driver . log . length ) . toEqual ( 0 ) ;
195
+
196
+ cmp . exp = false ;
197
+ fixture . detectChanges ( ) ;
198
+
199
+ expect ( driver . log . length ) . toEqual ( 1 ) ;
200
+
201
+ var animation = driver . log [ 0 ] ;
202
+ expect ( animation [ 'duration' ] ) . toEqual ( 999 ) ;
203
+ } ) ) ;
204
+
205
+ it ( 'should throw an error when an unsupported alias is detected which is prefixed a colon value' ,
206
+ fakeAsync ( ( ) => {
207
+ TestBed . overrideComponent ( DummyIfCmp , {
208
+ set : {
209
+ template : `
210
+ <div *ngIf="exp" [@myAnimation]="exp"></div>
211
+ ` ,
212
+ animations : [ trigger (
213
+ 'myAnimation' ,
214
+ [ transition ( ':dont_leave_me' , [ animate ( '444ms' , style ( { opacity : 0 } ) ) ] ) ] ) ]
215
+ }
216
+ } ) ;
217
+
218
+ var message = '' ;
219
+ try {
220
+ let fixture = TestBed . createComponent ( DummyIfCmp ) ;
221
+ } catch ( e ) {
222
+ message = e . message ;
223
+ }
224
+
225
+ expect ( message ) . toMatch (
226
+ / t h e t r a n s i t i o n a l i a s v a l u e " : d o n t _ l e a v e _ m e " i s n o t s u p p o r t e d / ) ;
227
+ } ) ) ;
228
+ } ) ;
229
+
149
230
it ( 'should animate between * and void and back even when no expression is assigned' ,
150
231
fakeAsync ( ( ) => {
151
232
TestBed . overrideComponent ( DummyIfCmp , {
0 commit comments