testing.mjs 1.5 KB

123456789101112131415161718192021222324252627282930313233343536
  1. import { M as MatOptionHarness } from '../option-harness-BFcc-M_4.mjs';
  2. import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
  3. /** Harness for interacting with a `mat-optgroup` in tests. */
  4. class MatOptgroupHarness extends ComponentHarness {
  5. /** Selector used to locate option group instances. */
  6. static hostSelector = '.mat-mdc-optgroup';
  7. _label = this.locatorFor('.mat-mdc-optgroup-label');
  8. /**
  9. * Gets a `HarnessPredicate` that can be used to search for a option group with specific
  10. * attributes.
  11. * @param options Options for filtering which option instances are considered a match.
  12. * @return a `HarnessPredicate` configured with the given options.
  13. */
  14. static with(options = {}) {
  15. return new HarnessPredicate(this, options).addOption('labelText', options.labelText, async (harness, title) => HarnessPredicate.stringMatches(await harness.getLabelText(), title));
  16. }
  17. /** Gets the option group's label text. */
  18. async getLabelText() {
  19. return (await this._label()).text();
  20. }
  21. /** Gets whether the option group is disabled. */
  22. async isDisabled() {
  23. return (await (await this.host()).getAttribute('aria-disabled')) === 'true';
  24. }
  25. /**
  26. * Gets the options that are inside the group.
  27. * @param filter Optionally filters which options are included.
  28. */
  29. async getOptions(filter = {}) {
  30. return this.locatorForAll(MatOptionHarness.with(filter))();
  31. }
  32. }
  33. export { MatOptgroupHarness, MatOptionHarness };
  34. //# sourceMappingURL=testing.mjs.map