diff --git a/src/cdk/drag-drop/directives/drag.spec.ts b/src/cdk/drag-drop/directives/drag.spec.ts index e735ea1e5906..f3c8e5496f48 100644 --- a/src/cdk/drag-drop/directives/drag.spec.ts +++ b/src/cdk/drag-drop/directives/drag.spec.ts @@ -2978,6 +2978,21 @@ describe('CdkDrag', () => { expect(preview.textContent!.trim()).toContain('Hello One'); })); + it('should handle custom preview with multiple root nodes', fakeAsync(() => { + const fixture = createComponent(DraggableInDropZoneWithCustomMultiNodePreview); + fixture.detectChanges(); + const item = fixture.componentInstance.dragItems.toArray()[1].element.nativeElement; + + expect(() => { + startDraggingViaMouse(fixture, item); + }).not.toThrow(); + + const preview = document.querySelector('.cdk-drag-preview')! as HTMLElement; + + expect(preview).toBeTruthy(); + expect(preview.textContent!.trim()).toContain('HelloOne'); + })); + it('should be able to customize the placeholder', fakeAsync(() => { const fixture = createComponent(DraggableInDropZoneWithCustomPlaceholder); fixture.detectChanges(); @@ -3050,6 +3065,21 @@ describe('CdkDrag', () => { expect(placeholder.textContent!.trim()).toContain('Hello One'); })); + it('should handle custom placeholder with multiple root nodes', fakeAsync(() => { + const fixture = createComponent(DraggableInDropZoneWithCustomMultiNodePlaceholder); + fixture.detectChanges(); + const item = fixture.componentInstance.dragItems.toArray()[1].element.nativeElement; + + expect(() => { + startDraggingViaMouse(fixture, item); + }).not.toThrow(); + + const placeholder = document.querySelector('.cdk-drag-placeholder')! as HTMLElement; + + expect(placeholder).toBeTruthy(); + expect(placeholder.textContent!.trim()).toContain('HelloOne'); + })); + it('should clear the `transform` value from siblings when item is dropped`', fakeAsync(() => { const fixture = createComponent(DraggableInDropZone); fixture.detectChanges(); @@ -5192,6 +5222,28 @@ class DraggableInDropZoneWithCustomTextOnlyPreview { } +@Component({ + template: ` +