Skip to content

Commit

Permalink
address comments
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalerba committed Oct 17, 2019
1 parent dc45372 commit 25daee6
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/cdk/testing/harness-environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ export abstract class HarnessEnvironment<E> implements HarnessLoader, LocatorFac
// Implemented as part of the `LocatorFactory` interface.
async harnessLoaderForOptional(selector: string): Promise<HarnessLoader | null> {
const elements = await this.getAllRawElements(selector);
return elements[0] && this.createEnvironment(elements[0]);
return elements[0] ? this.createEnvironment(elements[0]) : null;
}

// Implemented as part of the `LocatorFactory` interface.
Expand Down
2 changes: 1 addition & 1 deletion src/material/tabs/testing/shared.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ export function runHarnessTests(
it('should throw error when attempting to select invalid tab', async () => {
const tabGroup = await loader.getHarness(tabGroupHarness);
await expectAsyncError(() => tabGroup.selectTab({label: 'Fake'}),
/Error: Cannot find mat-tab matching {"label":"Fake"}/);
/Error: Cannot find mat-tab matching filter {"label":"Fake"}/);
});

it('should be able to get label of tabs', async () => {
Expand Down
2 changes: 1 addition & 1 deletion src/material/tabs/testing/tab-group-harness.ts
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ export class MatTabGroupHarness extends ComponentHarness {
async selectTab(filter: TabHarnessFilters = {}): Promise<void> {
const tabs = await this.getTabs(filter);
if (!tabs.length) {
throw Error(`Cannot find mat-tab matching ${JSON.stringify(filter)}`);
throw Error(`Cannot find mat-tab matching filter ${JSON.stringify(filter)}`);
}
await tabs[0].select();
}
Expand Down
4 changes: 4 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,10 @@ export class MatTabHarness extends ComponentHarness {
await (await this.host()).click();
}

/**
* Gets a `HarnessLoader` that can be used to load harnesses for components within the tab's
* content area.
*/
async getHarnessLoaderForContent(): Promise<HarnessLoader> {
const contentId = await this._getContentId();
return this.documentRootLocatorFactory().harnessLoaderFor(`#${contentId}`);
Expand Down

0 comments on commit 25daee6

Please sign in to comment.