UNPKG

@angular/material

Version:
1 lines 3.31 kB
{"version":3,"file":"core-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/core/testing/optgroup-harness.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.dev/license\n */\n\nimport {\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {OptgroupHarnessFilters} from './optgroup-harness-filters';\nimport {MatOptionHarness} from './option-harness';\nimport {OptionHarnessFilters} from './option-harness-filters';\n\n/** Harness for interacting with a `mat-optgroup` in tests. */\nexport class MatOptgroupHarness extends ComponentHarness {\n /** Selector used to locate option group instances. */\n static hostSelector = '.mat-mdc-optgroup';\n private _label = this.locatorFor('.mat-mdc-optgroup-label');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a option group with specific\n * attributes.\n * @param options Options for filtering which option instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatOptgroupHarness>(\n this: ComponentHarnessConstructor<T>,\n options: OptgroupHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options).addOption(\n 'labelText',\n options.labelText,\n async (harness, title) => HarnessPredicate.stringMatches(await harness.getLabelText(), title),\n );\n }\n\n /** Gets the option group's label text. */\n async getLabelText(): Promise<string> {\n return (await this._label()).text();\n }\n\n /** Gets whether the option group is disabled. */\n async isDisabled(): Promise<boolean> {\n return (await (await this.host()).getAttribute('aria-disabled')) === 'true';\n }\n\n /**\n * Gets the options that are inside the group.\n * @param filter Optionally filters which options are included.\n */\n async getOptions(filter: OptionHarnessFilters = {}): Promise<MatOptionHarness[]> {\n return this.locatorForAll(MatOptionHarness.with(filter))();\n }\n}\n"],"names":["MatOptgroupHarness","ComponentHarness","hostSelector","_label","locatorFor","with","options","HarnessPredicate","addOption","labelText","harness","title","stringMatches","getLabelText","text","isDisabled","host","getAttribute","getOptions","filter","locatorForAll","MatOptionHarness"],"mappings":";;;AAkBM,MAAOA,kBAAmB,SAAQC,gBAAgB,CAAA;EAEtD,OAAOC,YAAY,GAAG,mBAAmB;AACjCC,EAAAA,MAAM,GAAG,IAAI,CAACC,UAAU,CAAC,yBAAyB,CAAC;AAQ3D,EAAA,OAAOC,IAAIA,CAETC,OAAA,GAAkC,EAAE,EAAA;AAEpC,IAAA,OAAO,IAAIC,gBAAgB,CAAC,IAAI,EAAED,OAAO,CAAC,CAACE,SAAS,CAClD,WAAW,EACXF,OAAO,CAACG,SAAS,EACjB,OAAOC,OAAO,EAAEC,KAAK,KAAKJ,gBAAgB,CAACK,aAAa,CAAC,MAAMF,OAAO,CAACG,YAAY,EAAE,EAAEF,KAAK,CAAC,CAC9F;AACH;EAGA,MAAME,YAAYA,GAAA;IAChB,OAAO,CAAC,MAAM,IAAI,CAACV,MAAM,EAAE,EAAEW,IAAI,EAAE;AACrC;EAGA,MAAMC,UAAUA,GAAA;AACd,IAAA,OAAO,CAAC,MAAM,CAAC,MAAM,IAAI,CAACC,IAAI,EAAE,EAAEC,YAAY,CAAC,eAAe,CAAC,MAAM,MAAM;AAC7E;AAMA,EAAA,MAAMC,UAAUA,CAACC,MAAA,GAA+B,EAAE,EAAA;AAChD,IAAA,OAAO,IAAI,CAACC,aAAa,CAACC,gBAAgB,CAAChB,IAAI,CAACc,MAAM,CAAC,CAAC,EAAE;AAC5D;;;;;"}