diff --git a/src/material/paginator/testing/paginator-harness.ts b/src/material/paginator/testing/paginator-harness.ts index 9e641bf93c81..6a0c3be4abcb 100644 --- a/src/material/paginator/testing/paginator-harness.ts +++ b/src/material/paginator/testing/paginator-harness.ts @@ -36,6 +36,18 @@ export abstract class _MatPaginatorHarnessBase extends ComponentHarness { return (await this._nextButton()).click(); } + /** Returns whether or not the next page button is disabled. */ + async isNextPageDisabled(): Promise { + const disabledValue = await (await this._nextButton()).getAttribute('disabled'); + return disabledValue == 'true'; + } + + /* Returns whether or not the previous page button is disabled. */ + async isPreviousPageDisabled(): Promise { + const disabledValue = await (await this._previousButton()).getAttribute('disabled'); + return disabledValue == 'true'; + } + /** Goes to the previous page in the paginator. */ async goToPreviousPage(): Promise { return (await this._previousButton()).click(); diff --git a/src/material/paginator/testing/shared.spec.ts b/src/material/paginator/testing/shared.spec.ts index 626f97a7255e..1d30165eb144 100644 --- a/src/material/paginator/testing/shared.spec.ts +++ b/src/material/paginator/testing/shared.spec.ts @@ -97,6 +97,17 @@ export function runHarnessTests( ); }); + it('should return whether or not the previous page is disabled', async () => { + const paginator = await loader.getHarness(paginatorHarness); + expect(await paginator.isPreviousPageDisabled()).toBe(true); + }); + + it('should return whether or not the next page is disabled', async () => { + const paginator = await loader.getHarness(paginatorHarness); + await paginator.goToLastPage(); + expect(await paginator.isNextPageDisabled()).toBe(true); + }); + it('should throw an error if the last page button is not available', async () => { const paginator = await loader.getHarness(paginatorHarness); diff --git a/tools/public_api_guard/material/paginator-testing.md b/tools/public_api_guard/material/paginator-testing.md index 21b38f749c68..e2349fa8936a 100644 --- a/tools/public_api_guard/material/paginator-testing.md +++ b/tools/public_api_guard/material/paginator-testing.md @@ -41,6 +41,9 @@ export abstract class _MatPaginatorHarnessBase extends ComponentHarness { goToLastPage(): Promise; goToNextPage(): Promise; goToPreviousPage(): Promise; + isNextPageDisabled(): Promise; + // (undocumented) + isPreviousPageDisabled(): Promise; // (undocumented) protected abstract _lastPageButton: AsyncFactoryFn; // (undocumented)