forked from NationalBankBelgium/stark
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
action-bar component app-data component app-menu component use harnesses for testing ISSUES CLOSED: NationalBankBelgium#2767
- Loading branch information
Showing
9 changed files
with
217 additions
and
159 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,2 @@ | ||
export * from "./components/app-data.component"; | ||
export * from "./components/app-data.component.harness"; |
52 changes: 52 additions & 0 deletions
52
packages/stark-ui/src/modules/app-data/components/app-data.component.harness.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import { ComponentHarness } from "@angular/cdk/testing"; | ||
import { MatLegacyMenuHarness } from "@angular/material/legacy-menu/testing"; | ||
|
||
export class StarkAppDataComponentHarness extends ComponentHarness { | ||
public static hostSelector = "stark-app-data"; | ||
|
||
protected getSummary = this.locatorForOptional(".stark-app-data-summary"); | ||
protected getDropdownDiv = this.locatorForOptional(".stark-app-data.dropdown"); | ||
protected getMenuDiv = this.locatorForOptional(".stark-app-data.menu"); | ||
|
||
public getDropdownHarness = this.locatorForOptional(MatLegacyMenuHarness); | ||
|
||
public async isSummaryPresent(): Promise<boolean> { | ||
const detail = await this.getSummary(); | ||
return !!detail; | ||
} | ||
|
||
public async getSummaryText(): Promise<string | undefined> { | ||
const summary = await this.getSummary(); | ||
return summary ? summary.text() : undefined; | ||
} | ||
|
||
public async isDropdownDivPresent(): Promise<boolean> { | ||
const dropdown = await this.getDropdownDiv(); | ||
return !!dropdown; | ||
} | ||
|
||
public async isMenuDivPresent(): Promise<boolean> { | ||
const menu = await this.getMenuDiv(); | ||
return !!menu; | ||
} | ||
|
||
public async getDropdownDetailContentText(): Promise<string | undefined> { | ||
const rootLocator = this.documentRootLocatorFactory(); | ||
const element = await rootLocator.locatorForOptional(".mat-menu-content")(); | ||
return element ? element.text() : undefined; | ||
} | ||
|
||
public async openDropdownDetail(): Promise<void> { | ||
const matMenuHarness = await this.getDropdownHarness(); | ||
if (matMenuHarness) { | ||
await matMenuHarness.open(); | ||
} | ||
} | ||
|
||
public async closeDropdownDetail(): Promise<void> { | ||
const matMenuHarness = await this.getDropdownHarness(); | ||
if (matMenuHarness) { | ||
await matMenuHarness.close(); | ||
} | ||
} | ||
} |
Oops, something went wrong.