@@ -28,7 +28,7 @@ describe('Animation', () => {
28
28
describe ( 'animate.leave' , ( ) => {
29
29
const styles = `
30
30
.fade {
31
- animation: fade-out 1s ;
31
+ animation: fade-out 1ms ;
32
32
}
33
33
@keyframes fade-out {
34
34
from {
@@ -70,7 +70,7 @@ describe('Animation', () => {
70
70
new AnimationEvent ( 'animationend' , { animationName : 'fade-out' } ) ,
71
71
) ;
72
72
expect ( fixture . nativeElement . outerHTML ) . not . toContain ( 'class="fade"' ) ;
73
- } , 100_000 ) ;
73
+ } ) ;
74
74
75
75
it ( 'should remove right away when animations are disabled' , ( ) => {
76
76
@Component ( {
@@ -96,10 +96,10 @@ describe('Animation', () => {
96
96
it ( 'should support string arrays' , ( ) => {
97
97
const multiple = `
98
98
.slide-out {
99
- animation: slide-out 2s ;
99
+ animation: slide-out 2ms ;
100
100
}
101
101
.fade {
102
- animation: fade-out 1s ;
102
+ animation: fade-out 1ms ;
103
103
}
104
104
@keyframes slide-out {
105
105
from {
@@ -155,6 +155,67 @@ describe('Animation', () => {
155
155
expect ( fixture . nativeElement . outerHTML ) . not . toContain ( 'class="slide-out fade"' ) ;
156
156
} ) ;
157
157
158
+ it ( 'should support multiple classes as a single string with spaces' , ( ) => {
159
+ const multiple = `
160
+ .slide-out {
161
+ animation: slide-out 2ms;
162
+ }
163
+ .fade {
164
+ animation: fade-out 1ms;
165
+ }
166
+ @keyframes slide-out {
167
+ from {
168
+ transform: translateX(0);
169
+ }
170
+ to {
171
+ transform: translateX(10px);
172
+ }
173
+ }
174
+ @keyframes fade-out {
175
+ from {
176
+ opacity: 1;
177
+ }
178
+ to {
179
+ opacity: 0;
180
+ }
181
+ }
182
+ ` ;
183
+ @Component ( {
184
+ selector : 'test-cmp' ,
185
+ styles : multiple ,
186
+ template :
187
+ '<div>@if (show()) {<p animate.leave="slide-out fade" #el>I should slide out</p>}</div>' ,
188
+ encapsulation : ViewEncapsulation . None ,
189
+ } )
190
+ class TestComponent {
191
+ show = signal ( true ) ;
192
+ @ViewChild ( 'el' , { read : ElementRef } ) el ! : ElementRef < HTMLParagraphElement > ;
193
+ }
194
+
195
+ TestBed . configureTestingModule ( { animationsEnabled : true } ) ;
196
+
197
+ const fixture = TestBed . createComponent ( TestComponent ) ;
198
+ const cmp = fixture . componentInstance ;
199
+ fixture . detectChanges ( ) ;
200
+ const paragragh = fixture . debugElement . query ( By . css ( 'p' ) ) ;
201
+
202
+ expect ( fixture . nativeElement . outerHTML ) . not . toContain ( 'class="slide-out fade"' ) ;
203
+ cmp . show . set ( false ) ;
204
+ fixture . detectChanges ( ) ;
205
+ expect ( cmp . show ( ) ) . toBeFalsy ( ) ;
206
+ fixture . detectChanges ( ) ;
207
+ paragragh . nativeElement . dispatchEvent ( new AnimationEvent ( 'animationstart' ) ) ;
208
+ expect ( fixture . nativeElement . outerHTML ) . toContain ( 'class="slide-out fade"' ) ;
209
+ fixture . detectChanges ( ) ;
210
+ paragragh . nativeElement . dispatchEvent (
211
+ new AnimationEvent ( 'animationend' , { animationName : 'fade-out' } ) ,
212
+ ) ;
213
+ paragragh . nativeElement . dispatchEvent (
214
+ new AnimationEvent ( 'animationend' , { animationName : 'slide-out' } ) ,
215
+ ) ;
216
+ expect ( fixture . nativeElement . outerHTML ) . not . toContain ( 'class="slide-out fade"' ) ;
217
+ } ) ;
218
+
158
219
it ( 'should support function syntax' , ( ) => {
159
220
@Component ( {
160
221
selector : 'test-cmp' ,
@@ -224,10 +285,10 @@ describe('Animation', () => {
224
285
it ( 'should compose class list when host binding and regular binding' , ( ) => {
225
286
const multiple = `
226
287
.slide-out {
227
- animation: slide-out 2s ;
288
+ animation: slide-out 2ms ;
228
289
}
229
290
.fade {
230
- animation: fade-out 1s ;
291
+ animation: fade-out 1ms ;
231
292
}
232
293
@keyframes slide-out {
233
294
from {
@@ -301,10 +362,10 @@ describe('Animation', () => {
301
362
it ( 'should compose class list when host binding on a directive and regular binding' , ( ) => {
302
363
const multiple = `
303
364
.slide-out {
304
- animation: slide-out 2s ;
365
+ animation: slide-out 2ms ;
305
366
}
306
367
.fade {
307
- animation: fade-out 1s ;
368
+ animation: fade-out 1ms ;
308
369
}
309
370
@keyframes slide-out {
310
371
from {
@@ -376,10 +437,10 @@ describe('Animation', () => {
376
437
it ( 'should compose class list when host binding a string and regular class strings' , ( ) => {
377
438
const multiple = `
378
439
.slide-out {
379
- animation: slide-out 2s ;
440
+ animation: slide-out 2ms ;
380
441
}
381
442
.fade {
382
- animation: fade-out 1s ;
443
+ animation: fade-out 1ms ;
383
444
}
384
445
@keyframes slide-out {
385
446
from {
@@ -448,10 +509,10 @@ describe('Animation', () => {
448
509
describe ( 'animate.enter' , ( ) => {
449
510
const styles = `
450
511
.slide-in {
451
- animation: slide-in 1s ;
512
+ animation: slide-in 1ms ;
452
513
}
453
514
.fade-in {
454
- animation: fade-in 2s ;
515
+ animation: fade-in 2ms ;
455
516
}
456
517
@keyframes slide-in {
457
518
from {
@@ -574,10 +635,10 @@ describe('Animation', () => {
574
635
it ( 'should support string arrays' , ( ) => {
575
636
const multiple = `
576
637
.slide-in {
577
- animation: slide-in 1s ;
638
+ animation: slide-in 1ms ;
578
639
}
579
640
.fade-in {
580
- animation: fade-in 2s ;
641
+ animation: fade-in 2ms ;
581
642
}
582
643
@keyframes slide-in {
583
644
from {
@@ -619,6 +680,53 @@ describe('Animation', () => {
619
680
expect ( cmp . el . nativeElement . outerHTML ) . toContain ( 'class="slide-in fade-in"' ) ;
620
681
} ) ;
621
682
683
+ it ( 'should support multple classes as a single string separated by a space' , ( ) => {
684
+ const multiple = `
685
+ .slide-in {
686
+ animation: slide-in 1ms;
687
+ }
688
+ .fade-in {
689
+ animation: fade-in 2ms;
690
+ }
691
+ @keyframes slide-in {
692
+ from {
693
+ transform: translateX(-10px);
694
+ }
695
+ to {
696
+ transform: translateX(0);
697
+ }
698
+ }
699
+ @keyframes fade-in {
700
+ from {
701
+ opacity: 0;
702
+ }
703
+ to {
704
+ opacity: 1;
705
+ }
706
+ }
707
+ ` ;
708
+ @Component ( {
709
+ selector : 'test-cmp' ,
710
+ styles : multiple ,
711
+ template :
712
+ '<div>@if (show()) {<p animate.enter="slide-in fade-in" #el>I should slide in</p>}</div>' ,
713
+ encapsulation : ViewEncapsulation . None ,
714
+ } )
715
+ class TestComponent {
716
+ show = signal ( false ) ;
717
+ @ViewChild ( 'el' , { read : ElementRef } ) el ! : ElementRef < HTMLParagraphElement > ;
718
+ }
719
+ TestBed . configureTestingModule ( { animationsEnabled : true } ) ;
720
+
721
+ const fixture = TestBed . createComponent ( TestComponent ) ;
722
+ const cmp = fixture . componentInstance ;
723
+ fixture . detectChanges ( ) ;
724
+ cmp . show . set ( true ) ;
725
+ fixture . detectChanges ( ) ;
726
+ expect ( cmp . show ( ) ) . toBeTruthy ( ) ;
727
+ expect ( cmp . el . nativeElement . outerHTML ) . toContain ( 'class="slide-in fade-in"' ) ;
728
+ } ) ;
729
+
622
730
it ( 'should remove right away when animations are disabled' , fakeAsync ( ( ) => {
623
731
@Component ( {
624
732
selector : 'test-cmp' ,
0 commit comments