You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
79 lines
3.0 KiB
79 lines
3.0 KiB
import { __awaiter } from 'tslib';
|
|
import { ContentContainerComponentHarness, HarnessPredicate } from '@angular/cdk/testing';
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
/** Harness for interacting with a standard mat-card in tests. */
|
|
class MatCardHarness extends ContentContainerComponentHarness {
|
|
constructor() {
|
|
super(...arguments);
|
|
this._title = this.locatorForOptional('.mat-card-title');
|
|
this._subtitle = this.locatorForOptional('.mat-card-subtitle');
|
|
}
|
|
/**
|
|
* Gets a `HarnessPredicate` that can be used to search for a `MatCardHarness` that meets
|
|
* certain criteria.
|
|
* @param options Options for filtering which card instances are considered a match.
|
|
* @return a `HarnessPredicate` configured with the given options.
|
|
*/
|
|
static with(options = {}) {
|
|
return new HarnessPredicate(MatCardHarness, options)
|
|
.addOption('text', options.text, (harness, text) => HarnessPredicate.stringMatches(harness.getText(), text))
|
|
.addOption('title', options.title, (harness, title) => HarnessPredicate.stringMatches(harness.getTitleText(), title))
|
|
.addOption('subtitle', options.subtitle, (harness, subtitle) => HarnessPredicate.stringMatches(harness.getSubtitleText(), subtitle));
|
|
}
|
|
/** Gets all of the card's content as text. */
|
|
getText() {
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (yield this.host()).text();
|
|
});
|
|
}
|
|
/** Gets the cards's title text. */
|
|
getTitleText() {
|
|
var _a, _b;
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (_b = (_a = (yield this._title())) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : '';
|
|
});
|
|
}
|
|
/** Gets the cards's subtitle text. */
|
|
getSubtitleText() {
|
|
var _a, _b;
|
|
return __awaiter(this, void 0, void 0, function* () {
|
|
return (_b = (_a = (yield this._subtitle())) === null || _a === void 0 ? void 0 : _a.text()) !== null && _b !== void 0 ? _b : '';
|
|
});
|
|
}
|
|
}
|
|
/** The selector for the host element of a `MatCard` instance. */
|
|
MatCardHarness.hostSelector = '.mat-card';
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
/**
|
|
* @license
|
|
* Copyright Google LLC All Rights Reserved.
|
|
*
|
|
* Use of this source code is governed by an MIT-style license that can be
|
|
* found in the LICENSE file at https://angular.io/license
|
|
*/
|
|
|
|
export { MatCardHarness };
|
|
//# sourceMappingURL=testing.js.map
|