-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathtooltip.spec.ts
89 lines (82 loc) · 3.82 KB
/
tooltip.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
describe('Tooltip Demo Test', () => {
it('Navigate to tooltip section', () => {
cy.visit('http://localhost:3000/tooltip-demo-nav-link');
});
const defaultEntryDelay = 300;
const defaultExitDelay = 300;
it('Renders Tooltip on hover by default', () => {
['tooltip-children', 'tooltip-selector', 'tooltip-ref'].forEach((id) => {
cy.get(`[id="${id}-trigger"]`).then((tooltipTrigger: JQuery<HTMLButtonElement>) => {
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('not.exist');
cy.wrap(tooltipTrigger).trigger('mouseenter');
cy.wait(defaultEntryDelay);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('exist');
cy.wrap(tooltipTrigger).trigger('mouseleave');
cy.wait(defaultExitDelay);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('not.exist');
});
});
});
it('Renders Tooltip on focus by default', () => {
['tooltip-children', 'tooltip-selector', 'tooltip-ref'].forEach((id) => {
cy.get(`[id="${id}-trigger"]`).then((tooltipTrigger: JQuery<HTMLButtonElement>) => {
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('not.exist');
cy.wrap(tooltipTrigger).trigger('focus');
cy.wait(defaultEntryDelay);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('exist');
cy.wrap(tooltipTrigger).trigger('blur');
cy.wait(defaultExitDelay);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('not.exist');
});
});
});
it('Remains rendered when Tooltip is hovered', () => {
['tooltip-children', 'tooltip-selector', 'tooltip-ref'].forEach((id) => {
cy.get(`[id="${id}-trigger"]`).then((tooltipTrigger: JQuery<HTMLButtonElement>) => {
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('not.exist');
cy.wrap(tooltipTrigger).trigger('mouseenter');
cy.wait(defaultEntryDelay);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('exist');
});
cy.get(`#${id}-content.pf-v6-c-tooltip`).trigger('mouseenter');
cy.wait(defaultExitDelay + 100);
cy.get(`#${id}-content.pf-v6-c-tooltip`).should('exist');
cy.get(`#${id}-content.pf-v6-c-tooltip`).trigger('mouseleave').should('not.exist');
});
});
it('Renders tooltip on click', () => {
cy.get('#tooltip-click-trigger').trigger('mouseenter');
cy.get('#tooltip-click-content.pf-v6-c-tooltip').should('not.exist');
cy.get('#tooltip-click-trigger').trigger('focus');
cy.get('#tooltip-click-content.pf-v6-c-tooltip').should('not.exist');
cy.get('#tooltip-click-trigger').click();
cy.wait(defaultEntryDelay);
cy.get('#tooltip-click-content.pf-v6-c-tooltip').should('exist');
cy.get('#tooltip-click-content.pf-v6-c-tooltip').click();
cy.wait(defaultExitDelay);
cy.get('#tooltip-click-content.pf-v6-c-tooltip').should('not.exist');
});
it.skip('Renders with passed in entryDelay and exitDelay', () => {
cy.get('#tooltip-delay-trigger').trigger('mouseenter');
cy.wait(defaultEntryDelay);
cy.get('#tooltip-delay-content.pf-v6-c-tooltip').should('not.exist');
cy.wait(200);
cy.get('#tooltip-delay-content.pf-v6-c-tooltip').should('exist');
cy.get('#tooltip-delay-trigger').trigger('mouseleave');
cy.wait(defaultExitDelay);
cy.get('#tooltip-delay-content.pf-v6-c-tooltip').should('exist');
cy.wait(200);
cy.get('#tooltip-delay-content.pf-v6-c-tooltip').should('not.exist');
});
it('Renders with passed in animationDuration styling', () => {
cy.get('#tooltip-animationDuration-trigger').trigger('mouseenter');
cy.wait(defaultEntryDelay);
cy.get('#tooltip-animationDuration-content.pf-v6-c-tooltip').then((tooltipContent) => {
expect(tooltipContent)
.to.have.attr('style')
.match(/transition: opacity 500ms/);
});
cy.get('#tooltip-animationDuration-trigger').trigger('mouseleave');
cy.wait(defaultExitDelay);
});
});