Skip to content

Commit

Permalink
feat(material/select): harness throw when options are requested but p…
Browse files Browse the repository at this point in the history
…anel is closed
  • Loading branch information
behzadmehrabi committed Nov 9, 2023
1 parent 2e466be commit 6b05762
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions src/material/select/testing/select-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,9 @@ export class MatSelectHarness extends MatFormFieldControlHarness {

/** Gets the options inside the select panel. */
async getOptions(filter?: Omit<OptionHarnessFilters, 'ancestor'>): Promise<MatOptionHarness[]> {
if (!(await this.isOpen())) {
throw new Error('Unable to retrieve options for select. Select panel is closed.');
}
return this._documentRootLocator.locatorForAll(
this._optionClass.with({
...(filter || {}),
Expand All @@ -103,6 +106,9 @@ export class MatSelectHarness extends MatFormFieldControlHarness {
async getOptionGroups(
filter?: Omit<OptgroupHarnessFilters, 'ancestor'>,
): Promise<MatOptgroupHarness[]> {
if (!(await this.isOpen())) {
throw new Error('Unable to retrieve option groups for select. Select panel is closed.');
}
return this._documentRootLocator.locatorForAll(
this._optionGroupClass.with({
...(filter || {}),
Expand Down

0 comments on commit 6b05762

Please sign in to comment.