Skip to content

feat(cdk-experimental/testing): Add a public stabilize method to TestElement #16847

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Aug 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions src/cdk-experimental/testing/protractor/protractor-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -141,4 +141,6 @@ export class ProtractorElement implements TestElement {
async getProperty(name: string): Promise<any> {
return browser.executeScript(`return arguments[0][arguments[1]]`, this.element, name);
}

async forceStabilize(): Promise<void> {}
}
12 changes: 8 additions & 4 deletions src/cdk-experimental/testing/test-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,10 +90,7 @@ export interface TestElement {
/** Gets the text from the element. */
text(): Promise<string>;

/**
* Gets the value for the given attribute from the element. If the attribute does not exist,
* falls back to reading the property.
*/
/** Gets the value for the given attribute from the element. */
getAttribute(name: string): Promise<string | null>;

/** Checks whether the element has the given class. */
Expand All @@ -104,4 +101,11 @@ export interface TestElement {

/** Gets the value of a property of an element. */
getProperty(name: string): Promise<any>;

/**
* Flushes change detection and async tasks.
* In most cases it should not be necessary to call this. However, there may be some edge cases
* where it is needed to fully flush animation events.
*/
forceStabilize(): Promise<void>;
}
4 changes: 4 additions & 0 deletions src/cdk-experimental/testing/testbed/unit-test-element.ts
Original file line number Diff line number Diff line change
Expand Up @@ -137,4 +137,8 @@ export class UnitTestElement implements TestElement {
await this._stabilize();
return (this.element as any)[name];
}

async forceStabilize(): Promise<void> {
return this._stabilize();
}
}