UNPKG

@angular/material

Version:
1 lines 6.34 kB
{"version":3,"file":"sort-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/sort/testing/sort-header-harness.ts","../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/src/material/sort/testing/sort-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 {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {SortDirection} from '../../sort';\nimport {SortHeaderHarnessFilters} from './sort-harness-filters';\n\n/** Harness for interacting with a standard Angular Material sort header in tests. */\nexport class MatSortHeaderHarness extends ComponentHarness {\n static hostSelector = '.mat-sort-header';\n private _container = this.locatorFor('.mat-sort-header-container');\n\n /**\n * Gets a `HarnessPredicate` that can be used to\n * search for a sort header with specific attributes.\n */\n static with(options: SortHeaderHarnessFilters = {}): HarnessPredicate<MatSortHeaderHarness> {\n return new HarnessPredicate(MatSortHeaderHarness, options)\n .addOption('label', options.label, (harness, label) =>\n HarnessPredicate.stringMatches(harness.getLabel(), label),\n )\n .addOption('sortDirection', options.sortDirection, (harness, sortDirection) => {\n return HarnessPredicate.stringMatches(harness.getSortDirection(), sortDirection);\n });\n }\n\n /** Gets the label of the sort header. */\n async getLabel(): Promise<string> {\n return (await this._container()).text();\n }\n\n /** Gets the sorting direction of the header. */\n async getSortDirection(): Promise<SortDirection> {\n const host = await this.host();\n const ariaSort = await host.getAttribute('aria-sort');\n\n if (ariaSort === 'ascending') {\n return 'asc';\n } else if (ariaSort === 'descending') {\n return 'desc';\n }\n\n return '';\n }\n\n /** Gets whether the sort header is currently being sorted by. */\n async isActive(): Promise<boolean> {\n return !!(await this.getSortDirection());\n }\n\n /** Whether the sort header is disabled. */\n async isDisabled(): Promise<boolean> {\n return (await this.host()).hasClass('mat-sort-header-disabled');\n }\n\n /** Clicks the header to change its sorting direction. Only works if the header is enabled. */\n async click(): Promise<void> {\n return (await this.host()).click();\n }\n}\n","/**\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 {ComponentHarness, HarnessPredicate} from '@angular/cdk/testing';\nimport {SortHarnessFilters, SortHeaderHarnessFilters} from './sort-harness-filters';\nimport {MatSortHeaderHarness} from './sort-header-harness';\n\n/** Harness for interacting with a standard `mat-sort` in tests. */\nexport class MatSortHarness extends ComponentHarness {\n static hostSelector = '.mat-sort';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a `mat-sort` with specific attributes.\n * @param options Options for narrowing the search.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(options: SortHarnessFilters = {}): HarnessPredicate<MatSortHarness> {\n return new HarnessPredicate(MatSortHarness, options);\n }\n\n /** Gets all of the sort headers in the `mat-sort`. */\n async getSortHeaders(filter: SortHeaderHarnessFilters = {}): Promise<MatSortHeaderHarness[]> {\n return this.locatorForAll(MatSortHeaderHarness.with(filter))();\n }\n\n /** Gets the selected header in the `mat-sort`. */\n async getActiveHeader(): Promise<MatSortHeaderHarness | null> {\n const headers = await this.getSortHeaders();\n for (let i = 0; i < headers.length; i++) {\n if (await headers[i].isActive()) {\n return headers[i];\n }\n }\n return null;\n }\n}\n"],"names":["MatSortHeaderHarness","ComponentHarness","hostSelector","_container","locatorFor","with","options","HarnessPredicate","addOption","label","harness","stringMatches","getLabel","sortDirection","getSortDirection","text","host","ariaSort","getAttribute","isActive","isDisabled","hasClass","click","MatSortHarness","getSortHeaders","filter","locatorForAll","getActiveHeader","headers","i","length"],"mappings":";;AAaM,MAAOA,oBAAqB,SAAQC,gBAAgB,CAAA;EACxD,OAAOC,YAAY,GAAG,kBAAkB;AAChCC,EAAAA,UAAU,GAAG,IAAI,CAACC,UAAU,CAAC,4BAA4B,CAAC;AAMlE,EAAA,OAAOC,IAAIA,CAACC,OAAA,GAAoC,EAAE,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