{"version":3,"file":"paginator-testing.mjs","sources":["../../../../../darwin_arm64-fastbuild-ST-fdfa778d11ba/bin/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.dev/license\n */\n\nimport {\n  ComponentHarness,\n  ComponentHarnessConstructor,\n  HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {MatSelectHarness} from '../../select/testing';\nimport {coerceNumberProperty} from '@angular/cdk/coercion';\nimport {PaginatorHarnessFilters} from './paginator-harness-filters';\n\n/** Harness for interacting with a mat-paginator in tests. */\nexport class MatPaginatorHarness extends ComponentHarness {\n  /** Selector used to find paginator instances. */\n  static hostSelector = '.mat-mdc-paginator';\n  private _nextButton = this.locatorFor('.mat-mdc-paginator-navigation-next');\n  private _previousButton = this.locatorFor('.mat-mdc-paginator-navigation-previous');\n  private _firstPageButton = this.locatorForOptional('.mat-mdc-paginator-navigation-first');\n  private _lastPageButton = this.locatorForOptional('.mat-mdc-paginator-navigation-last');\n  _select = this.locatorForOptional(\n    MatSelectHarness.with({\n      ancestor: '.mat-mdc-paginator-page-size',\n    }),\n  );\n  private _pageSizeFallback = this.locatorFor('.mat-mdc-paginator-page-size-value');\n  _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<T extends MatPaginatorHarness>(\n    this: ComponentHarnessConstructor<T>,\n    options: PaginatorHarnessFilters = {},\n  ): HarnessPredicate<T> {\n    return new HarnessPredicate(this, options);\n  }\n\n  /** Goes to the next page in the paginator. */\n  async goToNextPage(): Promise<void> {\n    return (await this._nextButton()).click();\n  }\n\n  /** Returns whether or not the next page button is disabled. */\n  async isNextPageDisabled(): Promise<boolean> {\n    const disabledValue = await (await this._nextButton()).getAttribute('aria-disabled');\n    return disabledValue == 'true';\n  }\n\n  /* Returns whether or not the previous page button is disabled. */\n  async isPreviousPageDisabled(): Promise<boolean> {\n    const disabledValue = await (await this._previousButton()).getAttribute('aria-disabled');\n    return disabledValue == 'true';\n  }\n\n  /** Goes to the previous page in the paginator. */\n  async goToPreviousPage(): Promise<void> {\n    return (await this._previousButton()).click();\n  }\n\n  /** Goes to the first page in the paginator. */\n  async goToFirstPage(): Promise<void> {\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<void> {\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<void> {\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<number> {\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<string> {\n    return (await this._rangeLabel()).text();\n  }\n}\n"],"names":["MatPaginatorHarness","ComponentHarness","hostSelector","_nextButton","locatorFor","_previousButton","_firstPageButton","locatorForOptional","_lastPageButton","_select","MatSelectHarness","with","ancestor","_pageSizeFallback","_rangeLabel","options","HarnessPredicate","goToNextPage","click","isNextPageDisabled","disabledValue","getAttribute","isPreviousPageDisabled","goToPreviousPage","goToFirstPage","button","Error","goToLastPage","setPageSize","size","select","clickOptions","text","getPageSize","value","getValueText","coerceNumberProperty","getRangeLabel"],"mappings":";;;;;;AAkBM,MAAOA,mBAAoB,SAAQC,gBAAgB,CAAA;EAEvD,OAAOC,YAAY,GAAG,oBAAoB;AAClCC,EAAAA,WAAW,GAAG,IAAI,CAACC,UAAU,CAAC,oCAAoC,CAAC;AACnEC,EAAAA,eAAe,GAAG,IAAI,CAACD,UAAU,CAAC,wCAAwC,CAAC;AAC3EE,EAAAA,gBAAgB,GAAG,IAAI,CAACC,kBAAkB,CAAC,qCAAqC,CAAC;AACjFC,EAAAA,eAAe,GAAG,IAAI,CAACD,kBAAkB,CAAC,oCAAoC,CAAC;EACvFE,OAAO,GAAG,IAAI,CAACF,kBAAkB,CAC/BG,gBAAgB,CAACC,IAAI,CAAC;AACpBC,IAAAA,QAAQ,EAAE;AACX,GAAA,CAAC,CACH;AACOC,EAAAA,iBAAiB,GAAG,IAAI,CAACT,UAAU,CAAC,oCAAoC,CAAC;AACjFU,EAAAA,WAAW,GAAG,IAAI,CAACV,UAAU,CAAC,gCAAgC,CAAC;AAO/D,EAAA,OAAOO,IAAIA,CAETI,OAAA,GAAmC,EAAE,EAAA;AAErC,IAAA,OAAO,IAAIC,gBAAgB,CAAC,IAAI,EAAED,OAAO,CAAC;AAC5C;EAGA,MAAME,YAAYA,GAAA;IAChB,OAAO,CAAC,MAAM,IAAI,CAACd,WAAW,EAAE,EAAEe,KAAK,EAAE;AAC3C;EAGA,MAAMC,kBAAkBA,GAAA;AACtB,IAAA,MAAMC,aAAa,GAAG,MAAM,CAAC,MAAM,IAAI,CAACjB,WAAW,EAAE,EAAEkB,YAAY,CAAC,eAAe,CAAC;IACpF,OAAOD,aAAa,IAAI,MAAM;AAChC;EAGA,MAAME,sBAAsBA,GAAA;AAC1B,IAAA,MAAMF,aAA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