testing.mjs 1.6 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. import { ContentContainerComponentHarness, HarnessPredicate, parallel } from '@angular/cdk/testing';
  2. /** Selectors for different sections of the mat-toolbar that contain user content. */
  3. var MatToolbarSection;
  4. (function (MatToolbarSection) {
  5. MatToolbarSection["ROW"] = ".mat-toolbar-row";
  6. })(MatToolbarSection || (MatToolbarSection = {}));
  7. /** Harness for interacting with a standard mat-toolbar in tests. */
  8. class MatToolbarHarness extends ContentContainerComponentHarness {
  9. static hostSelector = '.mat-toolbar';
  10. _getRows = this.locatorForAll(MatToolbarSection.ROW);
  11. /**
  12. * Gets a `HarnessPredicate` that can be used to search for a `MatToolbarHarness` that meets
  13. * certain criteria.
  14. * @param options Options for filtering which card instances are considered a match.
  15. * @return a `HarnessPredicate` configured with the given options.
  16. */
  17. static with(options = {}) {
  18. return new HarnessPredicate(MatToolbarHarness, options).addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness._getText(), text));
  19. }
  20. /** Whether the toolbar has multiple rows. */
  21. async hasMultipleRows() {
  22. return (await this.host()).hasClass('mat-toolbar-multiple-rows');
  23. }
  24. /** Gets all of the toolbar's content as text. */
  25. async _getText() {
  26. return (await this.host()).text();
  27. }
  28. /** Gets the text of each row in the toolbar. */
  29. async getRowsAsText() {
  30. const rows = await this._getRows();
  31. return parallel(() => (rows.length ? rows.map(r => r.text()) : [this._getText()]));
  32. }
  33. }
  34. export { MatToolbarHarness, MatToolbarSection };
  35. //# sourceMappingURL=testing.mjs.map