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 | */
|
---|
8 | import { __awaiter } from "tslib";
|
---|
9 | import { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
---|
10 | /**
|
---|
11 | * Base class for the drawer harness functionality.
|
---|
12 | * @docs-private
|
---|
13 | */
|
---|
14 | export class MatDrawerHarnessBase extends ContentContainerComponentHarness {
|
---|
15 | /** Whether the drawer is open. */
|
---|
16 | isOpen() {
|
---|
17 | return __awaiter(this, void 0, void 0, function* () {
|
---|
18 | return (yield this.host()).hasClass('mat-drawer-opened');
|
---|
19 | });
|
---|
20 | }
|
---|
21 | /** Gets the position of the drawer inside its container. */
|
---|
22 | getPosition() {
|
---|
23 | return __awaiter(this, void 0, void 0, function* () {
|
---|
24 | const host = yield this.host();
|
---|
25 | return (yield host.hasClass('mat-drawer-end')) ? 'end' : 'start';
|
---|
26 | });
|
---|
27 | }
|
---|
28 | /** Gets the mode that the drawer is in. */
|
---|
29 | getMode() {
|
---|
30 | return __awaiter(this, void 0, void 0, function* () {
|
---|
31 | const host = yield this.host();
|
---|
32 | if (yield host.hasClass('mat-drawer-push')) {
|
---|
33 | return 'push';
|
---|
34 | }
|
---|
35 | if (yield host.hasClass('mat-drawer-side')) {
|
---|
36 | return 'side';
|
---|
37 | }
|
---|
38 | return 'over';
|
---|
39 | });
|
---|
40 | }
|
---|
41 | }
|
---|
42 | /** Harness for interacting with a standard mat-drawer in tests. */
|
---|
43 | export class MatDrawerHarness extends MatDrawerHarnessBase {
|
---|
44 | /**
|
---|
45 | * Gets a `HarnessPredicate` that can be used to search for a `MatDrawerHarness` that meets
|
---|
46 | * certain criteria.
|
---|
47 | * @param options Options for filtering which drawer instances are considered a match.
|
---|
48 | * @return a `HarnessPredicate` configured with the given options.
|
---|
49 | */
|
---|
50 | static with(options = {}) {
|
---|
51 | return new HarnessPredicate(MatDrawerHarness, options)
|
---|
52 | .addOption('position', options.position, (harness, position) => __awaiter(this, void 0, void 0, function* () { return (yield harness.getPosition()) === position; }));
|
---|
53 | }
|
---|
54 | }
|
---|
55 | /** The selector for the host element of a `MatDrawer` instance. */
|
---|
56 | MatDrawerHarness.hostSelector = '.mat-drawer';
|
---|
57 | //# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiZHJhd2VyLWhhcm5lc3MuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi8uLi8uLi8uLi8uLi8uLi9zcmMvbWF0ZXJpYWwvc2lkZW5hdi90ZXN0aW5nL2RyYXdlci1oYXJuZXNzLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOzs7Ozs7R0FNRzs7QUFFSCxPQUFPLEVBQUMsZ0NBQWdDLEVBQUUsZ0JBQWdCLEVBQUMsTUFBTSxzQkFBc0IsQ0FBQztBQUd4Rjs7O0dBR0c7QUFDSCxNQUFNLE9BQU8sb0JBQXFCLFNBQVEsZ0NBQXdDO0lBQ2hGLGtDQUFrQztJQUM1QixNQUFNOztZQUNWLE9BQU8sQ0FBQyxNQUFNLElBQUksQ0FBQyxJQUFJLEVBQUUsQ0FBQyxDQUFDLFFBQVEsQ0FBQyxtQkFBbUIsQ0FBQyxDQUFDO1FBQzNELENBQUM7S0FBQTtJQUVELDREQUE0RDtJQUN0RCxXQUFXOztZQUNmLE1BQU0sSUFBSSxHQUFHLE1BQU0sSUFBSSxDQUFDLElBQUksRUFBRSxDQUFDO1lBQy9CLE9BQU8sQ0FBQyxNQUFNLElBQUksQ0FBQyxRQUFRLENBQUMsZ0JBQWdCLENBQUMsQ0FBQyxDQUFDLENBQUMsQ0FBQyxLQUFLLENBQUMsQ0FBQyxDQUFDLE9BQU8sQ0FBQztRQUNuRSxDQUFDO0tBQUE7SUFFRCwyQ0FBMkM7SUFDck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