File tree Expand file tree Collapse file tree 2 files changed +1
-10
lines changed
src/material/autocomplete/testing Expand file tree Collapse file tree 2 files changed +1
-10
lines changed Original file line number Diff line number Diff line change @@ -82,9 +82,7 @@ export class MatAutocompleteHarness extends ComponentHarness {
82
82
83
83
/** Selects the first options matching the given filters. */
84
84
async selectOption ( filters : OptionHarnessFilters = { } ) : Promise < void > {
85
- if ( ! await this . isOpen ( ) ) {
86
- throw Error ( 'mat-autocomplete dropdown must be open to select an option' ) ;
87
- }
85
+ await this . focus ( ) ; // Focus the input to make sure the autocomplete panel is shown.
88
86
const options = await this . getOptions ( filters ) ;
89
87
if ( ! options . length ) {
90
88
throw Error ( `Could not find a mat-option matching ${ JSON . stringify ( filters ) } ` ) ;
Original file line number Diff line number Diff line change @@ -124,17 +124,10 @@ export function runHarnessTests(
124
124
125
125
it ( 'should be able to select option' , async ( ) => {
126
126
const input = await loader . getHarness ( autocompleteHarness . with ( { selector : '#plain' } ) ) ;
127
- await input . enterText ( 'New' ) ;
128
127
await input . selectOption ( { text : 'New York' } ) ;
129
128
expect ( await input . getValue ( ) ) . toBe ( 'NY' ) ;
130
129
} ) ;
131
130
132
- it ( 'should throw when selecting an option if autocomplete is not open' , async ( ) => {
133
- const input = await loader . getHarness ( autocompleteHarness . with ( { selector : '#plain' } ) ) ;
134
- await expectAsyncError ( ( ) => input . selectOption ( { text : 'New York' } ) ,
135
- / m a t - a u t o c o m p l e t e d r o p d o w n m u s t b e o p e n t o s e l e c t a n o p t i o n / ) ;
136
- } ) ;
137
-
138
131
it ( 'should throw when selecting an option that is not available' , async ( ) => {
139
132
const input = await loader . getHarness ( autocompleteHarness . with ( { selector : '#plain' } ) ) ;
140
133
await input . enterText ( 'New' ) ;
You can’t perform that action at this time.
0 commit comments