@angular/material
Version:
Angular Material
1 lines • 5.19 kB
Source Map (JSON)
{"version":3,"file":"testing.mjs","sources":["../../../../../../../src/material/card/testing/card-harness.ts","../../../../../../../src/material/card/testing/card-harness-filters.ts","../../../../../../../src/material/card/testing/public-api.ts","../../../../../../../src/material/card/testing/index.ts"],"sourcesContent":["/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {\n ComponentHarnessConstructor,\n ContentContainerComponentHarness,\n HarnessPredicate,\n} from '@angular/cdk/testing';\nimport {CardHarnessFilters} from './card-harness-filters';\n\n/** Selectors for different sections of the mat-card that can container user content. */\nexport const enum MatCardSection {\n HEADER = '.mat-mdc-card-header',\n CONTENT = '.mat-mdc-card-content',\n ACTIONS = '.mat-mdc-card-actions',\n FOOTER = '.mat-mdc-card-footer',\n}\n\n/** Harness for interacting with an MDC-based mat-card in tests. */\nexport class MatCardHarness extends ContentContainerComponentHarness<MatCardSection> {\n /** The selector for the host element of a `MatCard` instance. */\n static hostSelector = '.mat-mdc-card';\n\n /**\n * Gets a `HarnessPredicate` that can be used to search for a card with specific attributes.\n * @param options Options for filtering which card instances are considered a match.\n * @return a `HarnessPredicate` configured with the given options.\n */\n static with<T extends MatCardHarness>(\n this: ComponentHarnessConstructor<T>,\n options: CardHarnessFilters = {},\n ): HarnessPredicate<T> {\n return new HarnessPredicate(this, options)\n .addOption('text', options.text, (harness, text) =>\n HarnessPredicate.stringMatches(harness.getText(), text),\n )\n .addOption('title', options.title, (harness, title) =>\n HarnessPredicate.stringMatches(harness.getTitleText(), title),\n )\n .addOption('subtitle', options.subtitle, (harness, subtitle) =>\n HarnessPredicate.stringMatches(harness.getSubtitleText(), subtitle),\n );\n }\n\n private _title = this.locatorForOptional('.mat-mdc-card-title');\n private _subtitle = this.locatorForOptional('.mat-mdc-card-subtitle');\n\n /** Gets all of the card's content as text. */\n async getText(): Promise<string> {\n return (await this.host()).text();\n }\n\n /** Gets the cards's title text. */\n async getTitleText(): Promise<string> {\n return (await this._title())?.text() ?? '';\n }\n\n /** Gets the cards's subtitle text. */\n async getSubtitleText(): Promise<string> {\n return (await this._subtitle())?.text() ?? '';\n }\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nimport {BaseHarnessFilters} from '@angular/cdk/testing';\n\n/** A set of criteria that can be used to filter a list of `MatCardHarness` instances. */\nexport interface CardHarnessFilters extends BaseHarnessFilters {\n /** Only find instances whose text matches the given value. */\n text?: string | RegExp;\n /** Only find instances whose title matches the given value. */\n title?: string | RegExp;\n /** Only find instances whose subtitle matches the given value. */\n subtitle?: string | RegExp;\n}\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './card-harness';\nexport * from './card-harness-filters';\n","/**\n * @license\n * Copyright Google LLC All Rights Reserved.\n *\n * Use of this source code is governed by an MIT-style license that can be\n * found in the LICENSE file at https://angular.io/license\n */\n\nexport * from './public-api';\n"],"names":[],"mappings":";;AAAA;;;;;;AAMG;AAiBH;AACM,MAAO,cAAe,SAAQ,gCAAgD,CAAA;AAApF,IAAA,WAAA,GAAA;;AAyBU,QAAA,IAAA,CAAA,MAAM,GAAG,IAAI,CAAC,kBAAkB,CAAC,qBAAqB,CAAC,CAAC;AACxD,QAAA,IAAA,CAAA,SAAS,GAAG,IAAI,CAAC,kBAAkB,CAAC,wBAAwB,CAAC,CAAC;KAgBvE;AAtCC;;;;AAIG;AACH,IAAA,OAAO,IAAI,CAET,OAAA,GAA8B,EAAE,EAAA;AAEhC,QAAA,OAAO,IAAI,gBAAgB,CAAC,IAAI,EAAE,OAAO,CAAC;aACvC,SAAS,CAAC,MAAM,EAAE,OAAO,CAAC,IAAI,EAAE,CAAC,OAAO,EAAE,IAAI,KAC7C,g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