{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/paginator/testing/paginator-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.io/license\n */\n\nimport {\n AsyncFactoryFn,\n ComponentHarness,\n ComponentHarnessConstructor,\n HarnessPredicate,\n TestElement,\n} from '@angular/cdk/testing';\nimport {MatSelectHarness} from '@angular/material/select/testing';\nimport {coerceNumberProperty} from '@angular/cdk/coercion';\nimport {PaginatorHarnessFilters} from './paginator-harness-filters';\n\nexport abstract class _MatPaginatorHarnessBase extends ComponentHarness {\n protected abstract _nextButton: AsyncFactoryFn;\n protected abstract _previousButton: AsyncFactoryFn;\n protected abstract _firstPageButton: AsyncFactoryFn;\n protected abstract _lastPageButton: AsyncFactoryFn;\n protected abstract _select: AsyncFactoryFn<\n | (ComponentHarness & {\n getValueText(): Promise;\n clickOptions(...filters: unknown[]): Promise;\n })\n | null\n >;\n protected abstract _pageSizeFallback: AsyncFactoryFn;\n protected abstract _rangeLabel: AsyncFactoryFn;\n\n /** Goes to the next page in the paginator. */\n async goToNextPage(): Promise {\n return (await this._nextButton()).click();\n }\n\n /** Returns whether or not the next page button is disabled. */\n async isNextPageDisabled(): Promise {\n const disabledValue = await (await this._nextButton()).getAttribute('disabled');\n return disabledValue == 'true';\n }\n\n /* Returns whether or not the previous page button is disabled. */\n async isPreviousPageDisabled(): Promise {\n const disabledValue = await (await this._previousButton()).getAttribute('disabled');\n return disabledValue == 'true';\n }\n\n /** Goes to the previous page in the paginator. */\n async goToPreviousPage(): Promise {\n return (await this._previousButton()).click();\n }\n\n /** Goes to the first page in the paginator. */\n async goToFirstPage(): Promise {\n const button = await this._firstPageButton();\n\n // The first page button isn't enabled by default so we need to check for it.\n if (!button) {\n throw Error(\n 'Could not find first page button inside paginator. ' +\n 'Make sure that `showFirstLastButtons` is enabled.',\n );\n }\n\n return button.click();\n }\n\n /** Goes to the last page in the paginator. */\n async goToLastPage(): Promise {\n const button = await this._lastPageButton();\n\n // The last page button isn't enabled by default so we need to check for it.\n if (!button) {\n throw Error(\n 'Could not find last page button inside paginator. ' +\n 'Make sure that `showFirstLastButtons` is enabled.',\n );\n }\n\n return button.click();\n }\n\n /**\n * Sets the page size of the paginator.\n * @param size Page size that should be select.\n */\n async setPageSize(size: number): Promise {\n const select = await this._select();\n\n // The select is only available if the `pageSizeOptions` are\n // set to an array with more than one item.\n if (!select) {\n throw Error(\n 'Cannot find page size selector in paginator. ' +\n 'Make sure that the `pageSizeOptions` have been configured.',\n );\n }\n\n return select.clickOptions({text: `${size}`});\n }\n\n /** Gets the page size of the paginator. */\n async getPageSize(): Promise {\n const select = await this._select();\n const value = select ? select.getValueText() : (await this._pageSizeFallback()).text();\n return coerceNumberProperty(await value);\n }\n\n /** Gets the text of the range label of the paginator. */\n async getRangeLabel(): Promise {\n return (await this._rangeLabel()).text();\n }\n}\n\n/** Harness for interacting with an MDC-based mat-paginator in tests. */\nexport class MatPaginatorHarness extends _MatPaginatorHarnessBase {\n /** Selector used to find paginator instances. */\n static hostSelector = '.mat-mdc-paginator';\n protected _nextButton = this.locatorFor('.mat-mdc-paginator-navigation-next');\n protected _previousButton = this.locatorFor('.mat-mdc-paginator-navigation-previous');\n protected _firstPageButton = this.locatorForOptional('.mat-mdc-paginator-navigation-first');\n protected _lastPageButton = this.locatorForOptional('.mat-mdc-paginator-navigation-last');\n protected _select = this.locatorForOptional(\n MatSelectHarness.with({\n ancestor: '.mat-mdc-paginator-page-size',\n }),\n );\n protected _pageSizeFallback = this.locatorFor('.mat-mdc-paginator-page-size-value');\n protected _rangeLabel = this.locatorFor('.mat-mdc-paginator-range-label');\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a paginator with specific attributes.\n * @param options Options for filtering which paginator instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with(\n this: ComponentHarnessConstructor,\n options: PaginatorHarnessFilters = {},\n ): HarnessPredicate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