testing.mjs 1.1 KB

1234567891011121314151617181920212223242526272829
  1. import { coerceNumberProperty } from '@angular/cdk/coercion';
  2. import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
  3. /** Harness for interacting with a `mat-progress-bar` in tests. */
  4. class MatProgressBarHarness extends ComponentHarness {
  5. static hostSelector = '.mat-mdc-progress-bar';
  6. /**
  7. * Gets a `HarnessPredicate` that can be used to search for a progress bar with specific
  8. * attributes.
  9. * @param options Options for filtering which progress bar instances are considered a match.
  10. * @return a `HarnessPredicate` configured with the given options.
  11. */
  12. static with(options = {}) {
  13. return new HarnessPredicate(this, options);
  14. }
  15. /** Gets a promise for the progress bar's value. */
  16. async getValue() {
  17. const host = await this.host();
  18. const ariaValue = await host.getAttribute('aria-valuenow');
  19. return ariaValue ? coerceNumberProperty(ariaValue) : null;
  20. }
  21. /** Gets a promise for the progress bar's mode. */
  22. async getMode() {
  23. return (await this.host()).getAttribute('mode');
  24. }
  25. }
  26. export { MatProgressBarHarness };
  27. //# sourceMappingURL=testing.mjs.map