source: trip-planner-front/node_modules/@angular/material/esm2015/datepicker/testing/calendar-harness.js@ 6fe77af

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

initial commit

  • Property mode set to 100644
File size: 9.9 KB
Line 
1/**
2 * @license
3 * Copyright Google LLC All Rights Reserved.
4 *
5 * Use of this source code is governed by an MIT-style license that can be
6 * found in the LICENSE file at https://angular.io/license
7 */
8import { __awaiter } from "tslib";
9import { HarnessPredicate, ComponentHarness } from '@angular/cdk/testing';
10import { MatCalendarCellHarness } from './calendar-cell-harness';
11/** Harness for interacting with a standard Material calendar in tests. */
12export class MatCalendarHarness extends ComponentHarness {
13 constructor() {
14 super(...arguments);
15 /** Queries for the calendar's period toggle button. */
16 this._periodButton = this.locatorFor('.mat-calendar-period-button');
17 }
18 /**
19 * Gets a `HarnessPredicate` that can be used to search for a `MatCalendarHarness`
20 * that meets certain criteria.
21 * @param options Options for filtering which calendar instances are considered a match.
22 * @return a `HarnessPredicate` configured with the given options.
23 */
24 static with(options = {}) {
25 return new HarnessPredicate(MatCalendarHarness, options);
26 }
27 /**
28 * Gets a list of cells inside the calendar.
29 * @param filter Optionally filters which cells are included.
30 */
31 getCells(filter = {}) {
32 return __awaiter(this, void 0, void 0, function* () {
33 return this.locatorForAll(MatCalendarCellHarness.with(filter))();
34 });
35 }
36 /** Gets the current view that is being shown inside the calendar. */
37 getCurrentView() {
38 return __awaiter(this, void 0, void 0, function* () {
39 if (yield this.locatorForOptional('mat-multi-year-view')()) {
40 return 2 /* MULTI_YEAR */;
41 }
42 if (yield this.locatorForOptional('mat-year-view')()) {
43 return 1 /* YEAR */;
44 }
45 return 0 /* MONTH */;
46 });
47 }
48 /** Gets the label of the current calendar view. */
49 getCurrentViewLabel() {
50 return __awaiter(this, void 0, void 0, function* () {
51 return (yield this._periodButton()).text();
52 });
53 }
54 /** Changes the calendar view by clicking on the view toggle button. */
55 changeView() {
56 return __awaiter(this, void 0, void 0, function* () {
57 return (yield this._periodButton()).click();
58 });
59 }
60 /** Goes to the next page of the current view (e.g. next month when inside the month view). */
61 next() {
62 return __awaiter(this, void 0, void 0, function* () {
63 return (yield this.locatorFor('.mat-calendar-next-button')()).click();
64 });
65 }
66 /**
67 * Goes to the previous page of the current view
68 * (e.g. previous month when inside the month view).
69 */
70 previous() {
71 return __awaiter(this, void 0, void 0, function* () {
72 return (yield this.locatorFor('.mat-calendar-previous-button')()).click();
73 });
74 }
75 /**
76 * Selects a cell in the current calendar view.
77 * @param filter An optional filter to apply to the cells. The first cell matching the filter
78 * will be selected.
79 */
80 selectCell(filter = {}) {
81 return __awaiter(this, void 0, void 0, function* () {
82 const cells = yield this.getCells(filter);
83 if (!cells.length) {
84 throw Error(`Cannot find calendar cell matching filter ${JSON.stringify(filter)}`);
85 }
86 yield cells[0].select();
87 });
88 }
89}
90MatCalendarHarness.hostSelector = '.mat-calendar';
91//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2FsZW5kYXItaGFybmVzcy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uLy4uLy4uLy4uLy4uLy4uLy4uL3NyYy9tYXRlcmlhbC9kYXRlcGlja2VyL3Rlc3RpbmcvY2FsZW5kYXItaGFybmVzcy50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQTs7Ozs7O0dBTUc7O0FBRUgsT0FBTyxFQUFDLGdCQUFnQixFQUFFLGdCQUFnQixFQUFDLE1BQU0sc0JBQXNCLENBQUM7QUFFeEUsT0FBTyxFQUFDLHNCQUFzQixFQUFDLE1BQU0seUJBQXlCLENBQUM7QUFLL0QsMEVBQTBFO0FBQzFFLE1BQU0sT0FBTyxrQkFBbUIsU0FBUSxnQkFBZ0I7SUFBeEQ7O1FBR0UsdURBQXVEO1FBQy9DLGtCQUFhLEdBQUcsSUFBSSxDQUFDLFVBQVUsQ0FBQyw2QkFBNkIsQ0FBQyxDQUFDO0lBb0V6RSxDQUF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l0IHRoaXMubG9jYXRvckZvcignLm1hdC1jYWxlbmRhci1wcmV2aW91cy1idXR0b24nKSgpKS5jbGljaygpO1xuICB9XG5cbiAgLyoqXG4gICAqIFNlbGVjdHMgYSBjZWxsIGluIHRoZSBjdXJyZW50IGNhbGVuZGFyIHZpZXcuXG4gICAqIEBwYXJhbSBmaWx0ZXIgQW4gb3B0aW9uYWwgZmlsdGVyIHRvIGFwcGx5IHRvIHRoZSBjZWxscy4gVGhlIGZpcnN0IGNlbGwgbWF0Y2hpbmcgdGhlIGZpbHRlclxuICAgKiAgICAgd2lsbCBiZSBzZWxlY3RlZC5cbiAgICovXG4gIGFzeW5jIHNlbGVjdENlbGwoZmlsdGVyOiBDYWxlbmRhckNlbGxIYXJuZXNzRmlsdGVycyA9IHt9KTogUHJvbWlzZTx2b2lkPiB7XG4gICAgY29uc3QgY2VsbHMgPSBhd2FpdCB0aGlzLmdldENlbGxzKGZpbHRlcik7XG4gICAgaWYgKCFjZWxscy5sZW5ndGgpIHtcbiAgICAgIHRocm93IEVycm9yKGBDYW5ub3QgZmluZCBjYWxlbmRhciBjZWxsIG1hdGNoaW5nIGZpbHRlciAke0pTT04uc3RyaW5naWZ5KGZpbHRlcil9YCk7XG4gICAgfVxuICAgIGF3YWl0IGNlbGxzWzBdLnNlbGVjdCgpO1xuICB9XG59XG4iXX0=
Note: See TracBrowser for help on using the repository browser.