testing.mjs 1.3 KB

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