Skip to content

Commit

Permalink
add getTextContent to MatTabHarness
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Oct 17, 2019
1 parent 0da6d42 commit 50a1b19
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 0 deletions.
1 change: 1 addition & 0 deletions src/material/tabs/testing/shared.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,7 @@ export function runHarnessTests(
it('should be able to get harness loader for content element of active tab', async () => {
const tabGroup = await loader.getHarness(tabGroupHarness);
const tabs = await tabGroup.getTabs();
expect(await tabs[0].getTextContent()).toBe('Content 1');
const tabContentLoader = await tabs[0].getHarnessLoaderForContent();
const tabContentHarness = await tabContentLoader.getHarness(TestTabContentHarness);
expect(await (await tabContentHarness.host()).text()).toBe('Content 1');
Expand Down
7 changes: 7 additions & 0 deletions src/material/tabs/testing/tab-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,13 @@ export class MatTabHarness extends ComponentHarness {
await (await this.host()).click();
}

/** Gets the text content of the tab. */
async getTextContent(): Promise<string> {
const contentId = await this._getContentId();
const contentEl = await this.documentRootLocatorFactory().locatorFor(`#${contentId}`)();
return contentEl.text();
}

/**
* Gets a `HarnessLoader` that can be used to load harnesses for components within the tab's
* content area.
Expand Down

0 comments on commit 50a1b19

Please sign in to comment.