source: trip-planner-front/node_modules/@angular/material/fesm2015/paginator/testing.js@ 6a3a178

Last change on this file since 6a3a178 was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago

initial commit

  • Property mode set to 100644
File size: 5.1 KB
Line 
1import { __awaiter } from 'tslib';
2import { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
3import { MatSelectHarness } from '@angular/material/select/testing';
4import { coerceNumberProperty } from '@angular/cdk/coercion';
5
6/**
7 * @license
8 * Copyright Google LLC All Rights Reserved.
9 *
10 * Use of this source code is governed by an MIT-style license that can be
11 * found in the LICENSE file at https://angular.io/license
12 */
13class _MatPaginatorHarnessBase extends ComponentHarness {
14 /** Goes to the next page in the paginator. */
15 goToNextPage() {
16 return __awaiter(this, void 0, void 0, function* () {
17 return (yield this._nextButton()).click();
18 });
19 }
20 /** Goes to the previous page in the paginator. */
21 goToPreviousPage() {
22 return __awaiter(this, void 0, void 0, function* () {
23 return (yield this._previousButton()).click();
24 });
25 }
26 /** Goes to the first page in the paginator. */
27 goToFirstPage() {
28 return __awaiter(this, void 0, void 0, function* () {
29 const button = yield this._firstPageButton();
30 // The first page button isn't enabled by default so we need to check for it.
31 if (!button) {
32 throw Error('Could not find first page button inside paginator. ' +
33 'Make sure that `showFirstLastButtons` is enabled.');
34 }
35 return button.click();
36 });
37 }
38 /** Goes to the last page in the paginator. */
39 goToLastPage() {
40 return __awaiter(this, void 0, void 0, function* () {
41 const button = yield this._lastPageButton();
42 // The last page button isn't enabled by default so we need to check for it.
43 if (!button) {
44 throw Error('Could not find last page button inside paginator. ' +
45 'Make sure that `showFirstLastButtons` is enabled.');
46 }
47 return button.click();
48 });
49 }
50 /**
51 * Sets the page size of the paginator.
52 * @param size Page size that should be select.
53 */
54 setPageSize(size) {
55 return __awaiter(this, void 0, void 0, function* () {
56 const select = yield this._select();
57 // The select is only available if the `pageSizeOptions` are
58 // set to an array with more than one item.
59 if (!select) {
60 throw Error('Cannot find page size selector in paginator. ' +
61 'Make sure that the `pageSizeOptions` have been configured.');
62 }
63 return select.clickOptions({ text: `${size}` });
64 });
65 }
66 /** Gets the page size of the paginator. */
67 getPageSize() {
68 return __awaiter(this, void 0, void 0, function* () {
69 const select = yield this._select();
70 const value = select ? select.getValueText() : (yield this._pageSizeFallback()).text();
71 return coerceNumberProperty(yield value);
72 });
73 }
74 /** Gets the text of the range labe of the paginator. */
75 getRangeLabel() {
76 return __awaiter(this, void 0, void 0, function* () {
77 return (yield this._rangeLabel()).text();
78 });
79 }
80}
81/** Harness for interacting with a standard mat-paginator in tests. */
82class MatPaginatorHarness extends _MatPaginatorHarnessBase {
83 constructor() {
84 super(...arguments);
85 this._nextButton = this.locatorFor('.mat-paginator-navigation-next');
86 this._previousButton = this.locatorFor('.mat-paginator-navigation-previous');
87 this._firstPageButton = this.locatorForOptional('.mat-paginator-navigation-first');
88 this._lastPageButton = this.locatorForOptional('.mat-paginator-navigation-last');
89 this._select = this.locatorForOptional(MatSelectHarness.with({
90 ancestor: '.mat-paginator-page-size'
91 }));
92 this._pageSizeFallback = this.locatorFor('.mat-paginator-page-size-value');
93 this._rangeLabel = this.locatorFor('.mat-paginator-range-label');
94 }
95 /**
96 * Gets a `HarnessPredicate` that can be used to search for a `MatPaginatorHarness` that meets
97 * certain criteria.
98 * @param options Options for filtering which paginator instances are considered a match.
99 * @return a `HarnessPredicate` configured with the given options.
100 */
101 static with(options = {}) {
102 return new HarnessPredicate(MatPaginatorHarness, options);
103 }
104}
105/** Selector used to find paginator instances. */
106MatPaginatorHarness.hostSelector = '.mat-paginator';
107
108/**
109 * @license
110 * Copyright Google LLC All Rights Reserved.
111 *
112 * Use of this source code is governed by an MIT-style license that can be
113 * found in the LICENSE file at https://angular.io/license
114 */
115
116/**
117 * @license
118 * Copyright Google LLC All Rights Reserved.
119 *
120 * Use of this source code is governed by an MIT-style license that can be
121 * found in the LICENSE file at https://angular.io/license
122 */
123
124/**
125 * @license
126 * Copyright Google LLC All Rights Reserved.
127 *
128 * Use of this source code is governed by an MIT-style license that can be
129 * found in the LICENSE file at https://angular.io/license
130 */
131
132export { MatPaginatorHarness, _MatPaginatorHarnessBase };
133//# sourceMappingURL=testing.js.map
Note: See TracBrowser for help on using the repository browser.