-
Notifications
You must be signed in to change notification settings - Fork 6.8k
feat(material-experimental): add test harness for mat-tooltip #16676
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
Conversation
c878a24
to
0b1e1fb
Compare
Sets up a test harness for the current Material tooltip.
0b1e1fb
to
230d552
Compare
|
||
// TODO(crisbeto): this fails because we have a setTimeout inside the tooltip which | ||
// can't be flushed. Talk to Miles about how we should approach this in harnesses. | ||
// it('should be able to close a tooltip', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mmalerba In the tooltip's hide
method we do something like setTimeout(/* some close logic */, 0)
which I wasn't able to flush during the unit tests. I tried await
ing a setTimeout
, but it didn't help. I could probably get it to work if I use fakeAsync
with a tick
for the test, but that means that whoever is consuming the harness would have to know to that they have to use it. How should we handle this case? I'm guessing that we don't want to lock ourselves into using fakeAsync
or async
around some tests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say await
ing a setTimeout
, what did that code look like?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I had something like this:
function wait(time: number) {
return new Promise(resolve => {
setTimeout(resolve, time);
});
}
Then I had await wait(20000)
right before the assertions, but the timer still hadn't fired.
*/ | ||
|
||
export type TooltipHarnessFilters = { | ||
id?: string; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
triggerId
?
/** Gets an attribute value from the tooltip trigger. */ | ||
async getAttribute(attributeName: string): Promise<string|null> { | ||
return (await this.host()).getAttribute(attributeName); | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should just let people do host().getAttribute
themselves if they really need to get this level of flexibility
|
||
// TODO(crisbeto): this fails because we have a setTimeout inside the tooltip which | ||
// can't be flushed. Talk to Miles about how we should approach this in harnesses. | ||
// it('should be able to close a tooltip', async () => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
When you say await
ing a setTimeout
, what did that code look like?
Closing since this too out of date now. I'll take whatever I can from here and resubmit. |
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
This is redo of angular#16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
This is redo of #16676. Adds a test harness for `mat-tooltip`, as well as an API to move the pointer away from an element, as an opposite to `TestElement.hover`.
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
Sets up a test harness for the current Material tooltip.