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 {
8282
8383 /** Selects the first options matching the given filters. */
8484 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.
8886 const options = await this . getOptions ( filters ) ;
8987 if ( ! options . length ) {
9088 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(
124124
125125 it ( 'should be able to select option' , async ( ) => {
126126 const input = await loader . getHarness ( autocompleteHarness . with ( { selector : '#plain' } ) ) ;
127- await input . enterText ( 'New' ) ;
128127 await input . selectOption ( { text : 'New York' } ) ;
129128 expect ( await input . getValue ( ) ) . toBe ( 'NY' ) ;
130129 } ) ;
131130
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-
138131 it ( 'should throw when selecting an option that is not available' , async ( ) => {
139132 const input = await loader . getHarness ( autocompleteHarness . with ( { selector : '#plain' } ) ) ;
140133 await input . enterText ( 'New' ) ;
You can’t perform that action at this time.
0 commit comments