@@ -388,6 +388,39 @@ describe('CdkDrag', () => {
388
388
expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
389
389
} ) ) ;
390
390
391
+ it ( 'should be able to reset a freely-dragged item to its initial position' , fakeAsync ( ( ) => {
392
+ const fixture = createComponent ( StandaloneDraggable ) ;
393
+ fixture . detectChanges ( ) ;
394
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
395
+
396
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
397
+
398
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
399
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
400
+
401
+ fixture . componentInstance . dragInstance . reset ( ) ;
402
+
403
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
404
+ } ) ) ;
405
+
406
+ it ( 'should start dragging an item from its initial position after a reset' , fakeAsync ( ( ) => {
407
+ const fixture = createComponent ( StandaloneDraggable ) ;
408
+ fixture . detectChanges ( ) ;
409
+ const dragElement = fixture . componentInstance . dragElement . nativeElement ;
410
+
411
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
412
+
413
+ dragElementViaMouse ( fixture , dragElement , 50 , 100 ) ;
414
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(50px, 100px, 0px)' ) ;
415
+
416
+ fixture . componentInstance . dragInstance . reset ( ) ;
417
+
418
+ expect ( dragElement . style . transform ) . toBeFalsy ( ) ;
419
+
420
+ dragElementViaMouse ( fixture , dragElement , 25 , 50 ) ;
421
+ expect ( dragElement . style . transform ) . toBe ( 'translate3d(25px, 50px, 0px)' ) ;
422
+ } ) ) ;
423
+
391
424
} ) ;
392
425
393
426
describe ( 'draggable with a handle' , ( ) => {
0 commit comments