-
Notifications
You must be signed in to change notification settings - Fork 6.7k
/
autocomplete-harness.ts
54 lines (50 loc) · 1.99 KB
/
autocomplete-harness.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/**
* @license
* Copyright Google LLC All Rights Reserved.
*
* Use of this source code is governed by an MIT-style license that can be
* found in the LICENSE file at https://angular.io/license
*/
import {HarnessPredicate} from '@angular/cdk/testing';
import {
MatLegacyOptgroupHarness,
MatLegacyOptionHarness,
OptgroupHarnessFilters,
OptionHarnessFilters,
} from '@angular/material/legacy-core/testing';
import {_MatAutocompleteHarnessBase} from '@angular/material/autocomplete/testing';
import {LegacyAutocompleteHarnessFilters} from './autocomplete-harness-filters';
/**
* Harness for interacting with a standard mat-autocomplete in tests.
* @deprecated Use `MatAutocompleteHarness` from `@angular/material/autocomplete/testing` instead. See https://material.angular.io/guide/mdc-migration for information about migrating.
* @breaking-change 17.0.0
*/
export class MatLegacyAutocompleteHarness extends _MatAutocompleteHarnessBase<
typeof MatLegacyOptionHarness,
MatLegacyOptionHarness,
OptionHarnessFilters,
typeof MatLegacyOptgroupHarness,
MatLegacyOptgroupHarness,
OptgroupHarnessFilters
> {
protected _prefix = 'mat';
protected _optionClass = MatLegacyOptionHarness;
protected _optionGroupClass = MatLegacyOptgroupHarness;
/** The selector for the host element of a `MatAutocomplete` instance. */
static hostSelector = '.mat-autocomplete-trigger';
/**
* Gets a `HarnessPredicate` that can be used to search for a `MatAutocompleteHarness` that meets
* certain criteria.
* @param options Options for filtering which autocomplete instances are considered a match.
* @return a `HarnessPredicate` configured with the given options.
*/
static with(
options: LegacyAutocompleteHarnessFilters = {},
): HarnessPredicate<MatLegacyAutocompleteHarness> {
return new HarnessPredicate(MatLegacyAutocompleteHarness, options).addOption(
'value',
options.value,
(harness, value) => HarnessPredicate.stringMatches(harness.getValue(), value),
);
}
}