@angular/material
Version:
Angular Material
1 lines • 4.01 kB
Source Map (JSON)
{"version":3,"file":"_option-harness-chunk.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-199a4f3c4e20/bin/src/material/core/testing/option-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 ComponentHarnessConstructor,\n ContentContainerComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {OptionHarnessFilters} from './option-harness-filters';\n\n/** Harness for interacting with a `mat-option` in tests. */\nexport class MatOptionHarness extends ContentContainerComponentHarness {\n /** Selector used to locate option instances. */\n static hostSelector = '.mat-mdc-option';\n\n /** Element containing the option's text. */\n private _text = this.locatorFor('.mdc-list-item__primary-text');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for an option with specific 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 MatOptionHarness>(\n this: ComponentHarnessConstructor<T>,\n options: OptionHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options)\n .addOption('text', options.text, async (harness, title) =>\n HarnessPredicate.stringMatches(await harness.getText(), title),\n )\n .addOption(\n 'isSelected',\n options.isSelected,\n async (harness, isSelected) => (await harness.isSelected()) === isSelected,\n );\n }\n\n /** Clicks the option. */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n\n /** Gets the option's label text. */\n async getText(): Promise<string> {\n return (await this._text()).text();\n }\n\n /** Gets whether the option is disabled. */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('mdc-list-item--disabled');\n }\n\n /** Gets whether the option is selected. */\n async isSelected(): Promise<boolean> {\n return (await this.host()).hasClass('mdc-list-item--selected');\n }\n\n /** Gets whether the option is active. */\n async isActive(): Promise<boolean> {\n return (await this.host()).hasClass('mat-mdc-option-active');\n }\n\n /** Gets whether the option is in multiple selection mode. */\n async isMultiple(): Promise<boolean> {\n return (await this.host()).hasClass('mat-mdc-option-multiple');\n }\n}\n"],"names":["MatOptionHarness","ContentContainerComponentHarness","hostSelector","_text","locatorFor","with","options","HarnessPredicate","addOption","text","harness","title","stringMatches","getText","isSelected","click","host","isDisabled","hasClass","isActive","isMultiple"],"mappings":";;AAgBM,MAAOA,gBAAiB,SAAQC,gCAAgC,CAAA;EAEpE,OAAOC,YAAY,GAAG,iBAAiB;AAG/BC,EAAAA,KAAK,GAAG,IAAI,CAACC,UAAU,CAAC,8BAA8B,CAAC;AAO/D,EAAA,OAAOC,IAAIA,CAETC,OAAA,GAAgC,EAAE,EAAA;IAElC,OAAO,IAAIC,gBAAgB,CAAC,IAAI,EAAED,OAAO,CAAA,CACtCE,SAAS,CAAC,MAAM,EAAEF,OAAO,CAACG,IAAI,EAAE,OAAOC,OAAO,EAAEC,KAAK,KACpDJ,gBAAgB,CAACK,aAAa,CAAC,MAAMF,OAAO,CAACG,OAAO,EAAE,EAAEF,KAAK,CAAC,CAAA,CAE/DH,SAAS,CACR,YAAY,EACZF,OAAO,CAACQ,UAAU,EAClB,OAAOJ,OAAO,EAAEI,UAAU,KAAK,CAAC,MAAMJ,OAAO,CAACI,UAAU,EAAE,MAAMA,UAAU,CAC3E;AACL;EAGA,MAAMC,KAAKA,GAAA;IACT,OAAO,CAAC,MAAM,IAAI,CAACC,IAAI,EAAE,EAAED,KAAK,EAAE;AACpC;EAGA,MAAMF,OAAOA,GAAA;IACX,OAAO,CAAC,MAAM,IAAI,CAACV,KAAK,EAAE,EAAEM,IAAI,EAAE;AACpC;EAGA,MAAMQ,UAAUA,GAAA;IACd,OAAO,CAAC,MAAM,IAAI,CAACD,IAAI,EAAE,EAAEE,QAAQ,CAAC,yBAAyB,CAAC;AAChE;EAGA,MAAMJ,UAAUA,GAAA;IACd,OAAO,CAAC,MAAM,IAAI,CAACE,IAAI,EAAE,EAAEE,QAAQ,CAAC,yBAAyB,CAAC;AAChE;EAGA,MAAMC,QAAQA,GAAA;IACZ,OAAO,CAAC,MAAM,IAAI,CAACH,IAAI,EAAE,EAAEE,QAAQ,CAAC,uBAAuB,CAAC;AAC9D;EAGA,MAAME,UAAUA,GAAA;IACd,OAAO,CAAC,MAAM,IAAI,CAACJ,IAAI,EAAE,EAAEE,QAAQ,CAAC,yBAAyB,CAAC;AAChE;;;;;"}