Skip to content

Commit 50a1b19

Browse files
committed
add getTextContent to MatTabHarness
1 parent 0da6d42 commit 50a1b19

File tree

2 files changed

+8
-0
lines changed

2 files changed

+8
-0
lines changed

src/material/tabs/testing/shared.spec.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,7 @@ export function runHarnessTests(
9999
it('should be able to get harness loader for content element of active tab', async () => {
100100
const tabGroup = await loader.getHarness(tabGroupHarness);
101101
const tabs = await tabGroup.getTabs();
102+
expect(await tabs[0].getTextContent()).toBe('Content 1');
102103
const tabContentLoader = await tabs[0].getHarnessLoaderForContent();
103104
const tabContentHarness = await tabContentLoader.getHarness(TestTabContentHarness);
104105
expect(await (await tabContentHarness.host()).text()).toBe('Content 1');

src/material/tabs/testing/tab-harness.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,13 @@ export class MatTabHarness extends ComponentHarness {
6060
await (await this.host()).click();
6161
}
6262

63+
/** Gets the text content of the tab. */
64+
async getTextContent(): Promise<string> {
65+
const contentId = await this._getContentId();
66+
const contentEl = await this.documentRootLocatorFactory().locatorFor(`#${contentId}`)();
67+
return contentEl.text();
68+
}
69+
6370
/**
6471
* Gets a `HarnessLoader` that can be used to load harnesses for components within the tab's
6572
* content area.

0 commit comments

Comments
 (0)