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 | */
|
---|
8 | import { AsyncFactoryFn, ComponentHarness, ComponentHarnessConstructor, HarnessPredicate, TestElement } from '@angular/cdk/testing';
|
---|
9 | import { MatDatepickerInputHarness, MatDateRangeInputHarness } from '@angular/material/datepicker/testing';
|
---|
10 | import { MatFormFieldControlHarness } from '@angular/material/form-field/testing/control';
|
---|
11 | import { MatInputHarness } from '@angular/material/input/testing';
|
---|
12 | import { MatSelectHarness } from '@angular/material/select/testing';
|
---|
13 | import { FormFieldHarnessFilters } from './form-field-harness-filters';
|
---|
14 | /** Possible harnesses of controls which can be bound to a form-field. */
|
---|
15 | export declare type FormFieldControlHarness = MatInputHarness | MatSelectHarness | MatDatepickerInputHarness | MatDateRangeInputHarness;
|
---|
16 | export declare abstract class _MatFormFieldHarnessBase<ControlHarness extends MatFormFieldControlHarness> extends ComponentHarness {
|
---|
17 | protected abstract _prefixContainer: AsyncFactoryFn<TestElement | null>;
|
---|
18 | protected abstract _suffixContainer: AsyncFactoryFn<TestElement | null>;
|
---|
19 | protected abstract _label: AsyncFactoryFn<TestElement | null>;
|
---|
20 | protected abstract _errors: AsyncFactoryFn<TestElement[]>;
|
---|
21 | protected abstract _hints: AsyncFactoryFn<TestElement[]>;
|
---|
22 | protected abstract _inputControl: AsyncFactoryFn<ControlHarness | null>;
|
---|
23 | protected abstract _selectControl: AsyncFactoryFn<ControlHarness | null>;
|
---|
24 | protected abstract _datepickerInputControl: AsyncFactoryFn<ControlHarness | null>;
|
---|
25 | protected abstract _dateRangeInputControl: AsyncFactoryFn<ControlHarness | null>;
|
---|
26 | /** Gets the appearance of the form-field. */
|
---|
27 | abstract getAppearance(): Promise<string>;
|
---|
28 | /** Whether the label is currently floating. */
|
---|
29 | abstract isLabelFloating(): Promise<boolean>;
|
---|
30 | /** Whether the form-field has a label. */
|
---|
31 | abstract hasLabel(): Promise<boolean>;
|
---|
32 | /** Gets the label of the form-field. */
|
---|
33 | getLabel(): Promise<string | null>;
|
---|
34 | /** Whether the form-field has errors. */
|
---|
35 | hasErrors(): Promise<boolean>;
|
---|
36 | /** Whether the form-field is disabled. */
|
---|
37 | isDisabled(): Promise<boolean>;
|
---|
38 | /** Whether the form-field is currently autofilled. */
|
---|
39 | isAutofilled(): Promise<boolean>;
|
---|
40 | /**
|
---|
41 | * Gets the harness of the control that is bound to the form-field. Only
|
---|
42 | * default controls such as "MatInputHarness" and "MatSelectHarness" are
|
---|
43 | * supported.
|
---|
44 | */
|
---|
45 | getControl(): Promise<ControlHarness | null>;
|
---|
46 | /**
|
---|
47 | * Gets the harness of the control that is bound to the form-field. Searches
|
---|
48 | * for a control that matches the specified harness type.
|
---|
49 | */
|
---|
50 | getControl<X extends MatFormFieldControlHarness>(type: ComponentHarnessConstructor<X>): Promise<X | null>;
|
---|
51 | /**
|
---|
52 | * Gets the harness of the control that is bound to the form-field. Searches
|
---|
53 | * for a control that matches the specified harness predicate.
|
---|
54 | */
|
---|
55 | getControl<X extends MatFormFieldControlHarness>(type: HarnessPredicate<X>): Promise<X | null>;
|
---|
56 | /** Gets the theme color of the form-field. */
|
---|
57 | getThemeColor(): Promise<'primary' | 'accent' | 'warn'>;
|
---|
58 | /** Gets error messages which are currently displayed in the form-field. */
|
---|
59 | getTextErrors(): Promise<string[]>;
|
---|
60 | /** Gets hint messages which are currently displayed in the form-field. */
|
---|
61 | getTextHints(): Promise<string[]>;
|
---|
62 | /**
|
---|
63 | * Gets a reference to the container element which contains all projected
|
---|
64 | * prefixes of the form-field.
|
---|
65 | * @deprecated Use `getPrefixText` instead.
|
---|
66 | * @breaking-change 11.0.0
|
---|
67 | */
|
---|
68 | getHarnessLoaderForPrefix(): Promise<TestElement | null>;
|
---|
69 | /** Gets the text inside the prefix element. */
|
---|
70 | getPrefixText(): Promise<string>;
|
---|
71 | /**
|
---|
72 | * Gets a reference to the container element which contains all projected
|
---|
73 | * suffixes of the form-field.
|
---|
74 | * @deprecated Use `getSuffixText` instead.
|
---|
75 | * @breaking-change 11.0.0
|
---|
76 | */
|
---|
77 | getHarnessLoaderForSuffix(): Promise<TestElement | null>;
|
---|
78 | /** Gets the text inside the suffix element. */
|
---|
79 | getSuffixText(): Promise<string>;
|
---|
80 | /**
|
---|
81 | * Whether the form control has been touched. Returns "null"
|
---|
82 | * if no form control is set up.
|
---|
83 | */
|
---|
84 | isControlTouched(): Promise<boolean | null>;
|
---|
85 | /**
|
---|
86 | * Whether the form control is dirty. Returns "null"
|
---|
87 | * if no form control is set up.
|
---|
88 | */
|
---|
89 | isControlDirty(): Promise<boolean | null>;
|
---|
90 | /**
|
---|
91 | * Whether the form control is valid. Returns "null"
|
---|
92 | * if no form control is set up.
|
---|
93 | */
|
---|
94 | isControlValid(): Promise<boolean | null>;
|
---|
95 | /**
|
---|
96 | * Whether the form control is pending validation. Returns "null"
|
---|
97 | * if no form control is set up.
|
---|
98 | */
|
---|
99 | isControlPending(): Promise<boolean | null>;
|
---|
100 | /** Checks whether the form-field control has set up a form control. */
|
---|
101 | private _hasFormControl;
|
---|
102 | }
|
---|
103 | /** Harness for interacting with a standard Material form-field's in tests. */
|
---|
104 | export declare class MatFormFieldHarness extends _MatFormFieldHarnessBase<FormFieldControlHarness> {
|
---|
105 | static hostSelector: string;
|
---|
106 | /**
|
---|
107 | * Gets a `HarnessPredicate` that can be used to search for a `MatFormFieldHarness` that meets
|
---|
108 | * certain criteria.
|
---|
109 | * @param options Options for filtering which form field instances are considered a match.
|
---|
110 | * @return a `HarnessPredicate` configured with the given options.
|
---|
111 | */
|
---|
112 | static with(options?: FormFieldHarnessFilters): HarnessPredicate<MatFormFieldHarness>;
|
---|
113 | protected _prefixContainer: AsyncFactoryFn<TestElement | null>;
|
---|
114 | protected _suffixContainer: AsyncFactoryFn<TestElement | null>;
|
---|
115 | protected _label: AsyncFactoryFn<TestElement | null>;
|
---|
116 | protected _errors: AsyncFactoryFn<TestElement[]>;
|
---|
117 | protected _hints: AsyncFactoryFn<TestElement[]>;
|
---|
118 | protected _inputControl: AsyncFactoryFn<MatInputHarness | null>;
|
---|
119 | protected _selectControl: AsyncFactoryFn<MatSelectHarness | null>;
|
---|
120 | protected _datepickerInputControl: AsyncFactoryFn<MatDatepickerInputHarness | null>;
|
---|
121 | protected _dateRangeInputControl: AsyncFactoryFn<MatDateRangeInputHarness | null>;
|
---|
122 | /** Gets the appearance of the form-field. */
|
---|
123 | getAppearance(): Promise<'legacy' | 'standard' | 'fill' | 'outline'>;
|
---|
124 | /** Whether the form-field has a label. */
|
---|
125 | hasLabel(): Promise<boolean>;
|
---|
126 | /** Whether the label is currently floating. */
|
---|
127 | isLabelFloating(): Promise<boolean>;
|
---|
128 | }
|
---|