@@ -427,6 +427,33 @@ describe('CdkDrag', () => {
427
427
expect ( event . stopPropagation ) . toHaveBeenCalled ( ) ;
428
428
} ) ) ;
429
429
430
+ it ( 'should be able to reset a freely-dragged item to its initial position' , fakeAsync ( ( ) => {
431
+ const fixture = createComponent ( StandaloneDraggable ) ;
432
+ fixture . detectChanges ( ) ;
433
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
434
+
435
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
436
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
437
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
438
+
439
+ fixture . componentInstance . dragInstance . reset ( ) ;
440
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
441
+ } ) ) ;
442
+
443
+ it ( 'should start dragging an item from its initial position after a reset' , fakeAsync ( ( ) => {
444
+ const fixture = createComponent ( StandaloneDraggable ) ;
445
+ fixture . detectChanges ( ) ;
446
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
447
+
448
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
449
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
450
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
451
+ fixture . componentInstance . dragInstance . reset ( ) ;
452
+
453
+ dragElementViaMouse ( fixture , dragElement , 25 , 50 ) ;
454
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(25px, 50px, 0px)' ) ;
455
+ } ) ) ;
456
+
430
457
} ) ;
431
458
432
459
describe ( 'draggable with a handle' , ( ) => {
0 commit comments