1
- import { Directionality } from '../../bidi' ;
2
- import { Platform , _supportsShadowDom } from '../../platform' ;
3
- import { CdkScrollable , ViewportRuler } from '../../scrolling' ;
4
- import {
5
- createMouseEvent ,
6
- createTouchEvent ,
7
- dispatchEvent ,
8
- dispatchFakeEvent ,
9
- dispatchMouseEvent ,
10
- dispatchTouchEvent ,
11
- } from '../../testing/private' ;
12
1
import {
13
2
AfterViewInit ,
14
3
ChangeDetectionStrategy ,
@@ -25,20 +14,33 @@ import {
25
14
signal ,
26
15
} from '@angular/core' ;
27
16
import { ComponentFixture , TestBed , fakeAsync , flush , tick } from '@angular/core/testing' ;
28
- import { of as observableOf } from 'rxjs' ;
17
+ import { Platform , _supportsShadowDom } from '../../platform' ;
18
+ import { CdkScrollable , ViewportRuler } from '../../scrolling' ;
19
+ import {
20
+ createMouseEvent ,
21
+ createTouchEvent ,
22
+ dispatchEvent ,
23
+ dispatchFakeEvent ,
24
+ dispatchMouseEvent ,
25
+ dispatchTouchEvent ,
26
+ } from '../../testing/private' ;
29
27
30
28
import { extendStyles } from '../dom/styling' ;
31
29
import { CdkDragDrop , CdkDragEnter , CdkDragStart } from '../drag-events' ;
32
30
import { DragRef , Point , PreviewContainer } from '../drag-ref' ;
33
31
import { moveItemInArray } from '../drag-utils' ;
34
32
33
+ import { provideFakeDirectionality } from '@angular/cdk/testing/private/fake-directionality' ;
34
+ import { NgClass , NgFor , NgIf , NgTemplateOutlet } from '@angular/common' ;
35
35
import { CDK_DRAG_CONFIG , DragAxis , DragDropConfig , DropListOrientation } from './config' ;
36
36
import { CdkDrag } from './drag' ;
37
+ import { CdkDragPlaceholder } from './drag-placeholder' ;
38
+ import { CdkDragPreview } from './drag-preview' ;
37
39
import { CdkDropList } from './drop-list' ;
38
40
import { CdkDropListGroup } from './drop-list-group' ;
39
41
import {
40
- createComponent as _createComponent ,
41
42
DragDropTestConfig ,
43
+ createComponent as _createComponent ,
42
44
continueDraggingViaTouch ,
43
45
dragElementViaMouse ,
44
46
makeScrollable ,
@@ -47,9 +49,6 @@ import {
47
49
stopDraggingViaTouch ,
48
50
tickAnimationFrames ,
49
51
} from './test-utils.spec' ;
50
- import { NgClass , NgFor , NgIf , NgTemplateOutlet } from '@angular/common' ;
51
- import { CdkDragPreview } from './drag-preview' ;
52
- import { CdkDragPlaceholder } from './drag-placeholder' ;
53
52
54
53
export const ITEM_HEIGHT = 25 ;
55
54
export const ITEM_WIDTH = 75 ;
@@ -551,12 +550,7 @@ export function defineCommonDropListTests(config: {
551
550
552
551
it ( 'should dispatch the correct `dropped` event in RTL horizontal drop zone' , fakeAsync ( ( ) => {
553
552
const fixture = createComponent ( DraggableInHorizontalDropZone , {
554
- providers : [
555
- {
556
- provide : Directionality ,
557
- useValue : { value : 'rtl' , change : observableOf ( ) } ,
558
- } ,
559
- ] ,
553
+ providers : [ provideFakeDirectionality ( 'rtl' ) ] ,
560
554
} ) ;
561
555
562
556
fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
@@ -1200,12 +1194,7 @@ export function defineCommonDropListTests(config: {
1200
1194
1201
1195
it ( 'should pass the proper direction to the preview in rtl' , fakeAsync ( ( ) => {
1202
1196
const fixture = createComponent ( DraggableInDropZone , {
1203
- providers : [
1204
- {
1205
- provide : Directionality ,
1206
- useValue : { value : 'rtl' , change : observableOf ( ) } ,
1207
- } ,
1208
- ] ,
1197
+ providers : [ provideFakeDirectionality ( 'rtl' ) ] ,
1209
1198
} ) ;
1210
1199
1211
1200
fixture . detectChanges ( ) ;
@@ -2500,12 +2489,7 @@ export function defineCommonDropListTests(config: {
2500
2489
2501
2490
it ( 'should auto-scroll right if the user holds their pointer at right edge in rtl' , fakeAsync ( ( ) => {
2502
2491
const fixture = createComponent ( DraggableInScrollableHorizontalDropZone , {
2503
- providers : [
2504
- {
2505
- provide : Directionality ,
2506
- useValue : { value : 'rtl' , change : observableOf ( ) } ,
2507
- } ,
2508
- ] ,
2492
+ providers : [ provideFakeDirectionality ( 'rtl' ) ] ,
2509
2493
} ) ;
2510
2494
fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
2511
2495
fixture . detectChanges ( ) ;
@@ -2529,12 +2513,7 @@ export function defineCommonDropListTests(config: {
2529
2513
2530
2514
it ( 'should auto-scroll left if the user holds their pointer at left edge in rtl' , fakeAsync ( ( ) => {
2531
2515
const fixture = createComponent ( DraggableInScrollableHorizontalDropZone , {
2532
- providers : [
2533
- {
2534
- provide : Directionality ,
2535
- useValue : { value : 'rtl' , change : observableOf ( ) } ,
2536
- } ,
2537
- ] ,
2516
+ providers : [ provideFakeDirectionality ( 'rtl' ) ] ,
2538
2517
} ) ;
2539
2518
fixture . nativeElement . setAttribute ( 'dir' , 'rtl' ) ;
2540
2519
fixture . detectChanges ( ) ;
0 commit comments