MCPcopy Create free account
hub / github.com/angular/components / createComponent

Function createComponent

src/cdk/drag-drop/directives/test-utils.spec.ts:19–49  ·  view source on GitHub ↗
(
  componentType: Type<T>,
  config: DragDropTestConfig = {},
)

Source from the content-addressed store, hash-verified

17 * @param config Object that can be used to further configure the test.
18 */
19export function createComponent<T>(
20 componentType: Type<T>,
21 config: DragDropTestConfig = {},
22): ComponentFixture<T> {
23 const dragConfig: DragDropConfig = {
24 // We default the `dragDistance` to zero, because the majority of the tests
25 // don't care about it and drags are a lot easier to simulate when we don't
26 // have to deal with thresholds.
27 dragStartThreshold: config?.dragDistance ?? 0,
28 pointerDirectionChangeThreshold: 5,
29 listOrientation: config.listOrientation,
30 };
31
32 TestBed.configureTestingModule({
33 providers: [
34 {
35 provide: CDK_DRAG_CONFIG,
36 useValue: dragConfig,
37 },
38 ...(config.providers || []),
39 ],
40 });
41
42 if (config.encapsulation != null) {
43 TestBed.overrideComponent(componentType, {
44 set: {encapsulation: config.encapsulation},
45 });
46 }
47
48 return TestBed.createComponent<T>(componentType);
49}
50
51/**
52 * Drags an element to a position on the page using the mouse.

Calls

no outgoing calls

Tested by

no test coverage detected