source: trip-planner-front/node_modules/@angular/cdk/testing/test-element.d.ts@ e29cc2e

Last change on this file since e29cc2e was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.0 KB
RevLine 
[6a3a178]1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { ElementDimensions } from './element-dimensions';
9/** Modifier keys that may be held while typing. */
10export interface ModifierKeys {
11 control?: boolean;
12 alt?: boolean;
13 shift?: boolean;
14 meta?: boolean;
15}
16/** Data that can be attached to a custom event dispatched from a `TestElement`. */
17export declare type EventData = string | number | boolean | undefined | null | EventData[] | {
18 [key: string]: EventData;
19};
20/** An enum of non-text keys that can be used with the `sendKeys` method. */
21export declare enum TestKey {
22 BACKSPACE = 0,
23 TAB = 1,
24 ENTER = 2,
25 SHIFT = 3,
26 CONTROL = 4,
27 ALT = 5,
28 ESCAPE = 6,
29 PAGE_UP = 7,
30 PAGE_DOWN = 8,
31 END = 9,
32 HOME = 10,
33 LEFT_ARROW = 11,
34 UP_ARROW = 12,
35 RIGHT_ARROW = 13,
36 DOWN_ARROW = 14,
37 INSERT = 15,
38 DELETE = 16,
39 F1 = 17,
40 F2 = 18,
41 F3 = 19,
42 F4 = 20,
43 F5 = 21,
44 F6 = 22,
45 F7 = 23,
46 F8 = 24,
47 F9 = 25,
48 F10 = 26,
49 F11 = 27,
50 F12 = 28,
51 META = 29
52}
53/**
54 * This acts as a common interface for DOM elements across both unit and e2e tests. It is the
55 * interface through which the ComponentHarness interacts with the component's DOM.
56 */
57export interface TestElement {
58 /** Blur the element. */
59 blur(): Promise<void>;
60 /** Clear the element's input (for input and textarea elements only). */
61 clear(): Promise<void>;
62 /**
63 * Click the element at the default location for the current environment. If you need to guarantee
64 * the element is clicked at a specific location, consider using `click('center')` or
65 * `click(x, y)` instead.
66 */
67 click(modifiers?: ModifierKeys): Promise<void>;
68 /** Click the element at the element's center. */
69 click(location: 'center', modifiers?: ModifierKeys): Promise<void>;
70 /**
71 * Click the element at the specified coordinates relative to the top-left of the element.
72 * @param relativeX Coordinate within the element, along the X-axis at which to click.
73 * @param relativeY Coordinate within the element, along the Y-axis at which to click.
74 * @param modifiers Modifier keys held while clicking
75 */
76 click(relativeX: number, relativeY: number, modifiers?: ModifierKeys): Promise<void>;
77 /**
78 * Right clicks on the element at the specified coordinates relative to the top-left of it.
79 * @param relativeX Coordinate within the element, along the X-axis at which to click.
80 * @param relativeY Coordinate within the element, along the Y-axis at which to click.
81 * @param modifiers Modifier keys held while clicking
82 */
83 rightClick(relativeX: number, relativeY: number, modifiers?: ModifierKeys): Promise<void>;
84 /** Focus the element. */
85 focus(): Promise<void>;
86 /** Get the computed value of the given CSS property for the element. */
87 getCssValue(property: string): Promise<string>;
88 /** Hovers the mouse over the element. */
89 hover(): Promise<void>;
90 /** Moves the mouse away from the element. */
91 mouseAway(): Promise<void>;
92 /**
93 * Sends the given string to the input as a series of key presses. Also fires input events
94 * and attempts to add the string to the Element's value.
95 */
96 sendKeys(...keys: (string | TestKey)[]): Promise<void>;
97 /**
98 * Sends the given string to the input as a series of key presses. Also fires input events
99 * and attempts to add the string to the Element's value.
100 */
101 sendKeys(modifiers: ModifierKeys, ...keys: (string | TestKey)[]): Promise<void>;
102 /**
103 * Gets the text from the element.
104 * @param options Options that affect what text is included.
105 */
106 text(options?: TextOptions): Promise<string>;
107 /** Gets the value for the given attribute from the element. */
108 getAttribute(name: string): Promise<string | null>;
109 /** Checks whether the element has the given class. */
110 hasClass(name: string): Promise<boolean>;
111 /** Gets the dimensions of the element. */
112 getDimensions(): Promise<ElementDimensions>;
113 /** Gets the value of a property of an element. */
114 getProperty<T = any>(name: string): Promise<T>;
115 /** Checks whether this element matches the given selector. */
116 matchesSelector(selector: string): Promise<boolean>;
117 /** Checks whether the element is focused. */
118 isFocused(): Promise<boolean>;
119 /** Sets the value of a property of an input. */
120 setInputValue(value: string): Promise<void>;
121 /** Selects the options at the specified indexes inside of a native `select` element. */
122 selectOptions(...optionIndexes: number[]): Promise<void>;
123 /**
124 * Dispatches an event with a particular name.
125 * @param name Name of the event to be dispatched.
126 */
127 dispatchEvent(name: string, data?: Record<string, EventData>): Promise<void>;
128}
129export interface TextOptions {
130 /** Optional selector for elements to exclude. */
131 exclude?: string;
132}
Note: See TracBrowser for help on using the repository browser.