@@ -442,6 +442,32 @@ describe('CdkDrag', () => {
442
442
expect ( dragElement . style . touchAction )
443
443
. not . toEqual ( 'none' , 'should not disable touchAction on when there is a drag handle' ) ;
444
444
} ) ;
445
+ it ( 'should be able to reset a freely-dragged item to its initial position' , fakeAsync ( ( ) => {
446
+ const fixture = createComponent ( StandaloneDraggable ) ;
447
+ fixture . detectChanges ( ) ;
448
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
449
+
450
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
451
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
452
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
453
+
454
+ fixture . componentInstance . dragInstance . reset ( ) ;
455
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
456
+ } ) ) ;
457
+
458
+ it ( 'should start dragging an item from its initial position after a reset' , fakeAsync ( ( ) => {
459
+ const fixture = createComponent ( StandaloneDraggable ) ;
460
+ fixture . detectChanges ( ) ;
461
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
462
+
463
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
464
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
465
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
466
+ fixture . componentInstance . dragInstance . reset ( ) ;
467
+
468
+ dragElementViaMouse ( fixture , dragElement , 25 , 50 ) ;
469
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(25px, 50px, 0px)' ) ;
470
+ } ) ) ;
445
471
446
472
} ) ;
447
473
0 commit comments