@@ -569,6 +569,45 @@ describe('CdkDrag', () => {
569
569
. toEqual ( [ 'One' , 'Two' , 'Zero' , 'Three' ] ) ;
570
570
} ) ) ;
571
571
572
+ it ( 'should dispatch the correct `dropped` event in RTL horizontal drop zone' , fakeAsync ( ( ) => {
573
+ const fixture = createComponent ( DraggableInHorizontalDropZone , [ {
574
+ provide : Directionality ,
575
+ useValue : ( { value : 'rtl' } )
576
+ } ] ) ;
577
+
578
+ fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
579
+ fixture . detectChanges ( ) ;
580
+ const dragItems = fixture . componentInstance . dragItems ;
581
+
582
+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
583
+ . toEqual ( [ 'Zero' , 'One' , 'Two' , 'Three' ] ) ;
584
+
585
+ const firstItem = dragItems . first ;
586
+ const thirdItemRect = dragItems . toArray ( ) [ 2 ] . element . nativeElement . getBoundingClientRect ( ) ;
587
+
588
+ dragElementViaMouse ( fixture , firstItem . element . nativeElement ,
589
+ thirdItemRect . right - 1 , thirdItemRect . top + 1 ) ;
590
+ flush ( ) ;
591
+ fixture . detectChanges ( ) ;
592
+
593
+ expect ( fixture . componentInstance . droppedSpy ) . toHaveBeenCalledTimes ( 1 ) ;
594
+
595
+ const event = fixture . componentInstance . droppedSpy . calls . mostRecent ( ) . args [ 0 ] ;
596
+
597
+ // Assert the event like this, rather than `toHaveBeenCalledWith`, because Jasmine will
598
+ // go into an infinite loop trying to stringify the event, if the test fails.
599
+ expect ( event ) . toEqual ( {
600
+ previousIndex : 0 ,
601
+ currentIndex : 2 ,
602
+ item : firstItem ,
603
+ container : fixture . componentInstance . dropInstance ,
604
+ previousContainer : fixture . componentInstance . dropInstance
605
+ } ) ;
606
+
607
+ expect ( dragItems . map ( drag => drag . element . nativeElement . textContent ! . trim ( ) ) )
608
+ . toEqual ( [ 'One' , 'Two' , 'Zero' , 'Three' ] ) ;
609
+ } ) ) ;
610
+
572
611
it ( 'should not move items in a horizontal list if pointer is too far away' , fakeAsync ( ( ) => {
573
612
const fixture = createComponent ( DraggableInHorizontalDropZone ) ;
574
613
fixture . detectChanges ( ) ;
0 commit comments