source: trip-planner-front/node_modules/@angular/material/esm2015/stepper/testing/stepper-harness.js

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

initial commit

  • Property mode set to 100644
File size: 7.1 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 { ComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
10import { MatStepHarness } from './step-harness';
11/** Harness for interacting with a standard Material stepper in tests. */
12export class MatStepperHarness extends ComponentHarness {
13 /**
14 * Gets a `HarnessPredicate` that can be used to search for a `MatStepperHarness` that meets
15 * certain criteria.
16 * @param options Options for filtering which stepper instances are considered a match.
17 * @return a `HarnessPredicate` configured with the given options.
18 */
19 static with(options = {}) {
20 return new HarnessPredicate(MatStepperHarness, options)
21 .addOption('orientation', options.orientation, (harness, orientation) => __awaiter(this, void 0, void 0, function* () { return (yield harness.getOrientation()) === orientation; }));
22 }
23 /**
24 * Gets the list of steps in the stepper.
25 * @param filter Optionally filters which steps are included.
26 */
27 getSteps(filter = {}) {
28 return __awaiter(this, void 0, void 0, function* () {
29 return this.locatorForAll(MatStepHarness.with(filter))();
30 });
31 }
32 /** Gets the orientation of the stepper. */
33 getOrientation() {
34 return __awaiter(this, void 0, void 0, function* () {
35 const host = yield this.host();
36 return (yield host.hasClass('mat-stepper-horizontal')) ?
37 0 /* HORIZONTAL */ : 1 /* VERTICAL */;
38 });
39 }
40 /**
41 * Selects a step in this stepper.
42 * @param filter An optional filter to apply to the child steps. The first step matching the
43 * filter will be selected.
44 */
45 selectStep(filter = {}) {
46 return __awaiter(this, void 0, void 0, function* () {
47 const steps = yield this.getSteps(filter);
48 if (!steps.length) {
49 throw Error(`Cannot find mat-step matching filter ${JSON.stringify(filter)}`);
50 }
51 yield steps[0].select();
52 });
53 }
54}
55/** The selector for the host element of a `MatStepper` instance. */
56MatStepperHarness.hostSelector = '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