Skip to content

Commit

Permalink
chore(Tooltip): updated unit tests (patternfly#9295)
Browse files Browse the repository at this point in the history
* chore(Tooltip): updated unit tests

* Updated mock and tests

* Updated based on Austin feedback

* Updated integration tests

* Removed unused imports

* Updated remaining tests using Popper mock

* Removed extraenous snapshot test

* Removed test

* Split out onTooltipHidden test
  • Loading branch information
thatblindgeye authored and Titani committed Jul 31, 2023
1 parent 1e1fa7d commit 20e3c8f
Show file tree
Hide file tree
Showing 15 changed files with 498 additions and 143 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,11 @@ test('renders dropdown', () => {
});

test('passes children', () => {
render(<Dropdown toggle={(toggleRef) => toggle(toggleRef)}>{dropdownChildren}</Dropdown>);
render(
<Dropdown isOpen toggle={(toggleRef) => toggle(toggleRef)}>
{dropdownChildren}
</Dropdown>
);

expect(screen.getByText('Dropdown children')).toBeVisible();
});
Expand Down Expand Up @@ -112,7 +116,7 @@ test('passes zIndex to popper', () => {
test('does not pass isOpen to popper by default', () => {
render(<Dropdown toggle={(toggleRef) => toggle(toggleRef)}>{dropdownChildren}</Dropdown>);

expect(screen.getByText('isOpen: undefined')).toBeVisible();
expect(screen.getByText('isVisible: undefined')).toBeVisible();
});

test('passes isOpen to popper', () => {
Expand All @@ -122,7 +126,7 @@ test('passes isOpen to popper', () => {
</Dropdown>
);

expect(screen.getByText('isOpen: true')).toBeVisible();
expect(screen.getByText('isVisible: true')).toBeVisible();
});

/* no default tests for callback props
Expand All @@ -134,7 +138,7 @@ test('passes onSelect callback', async () => {

const onSelect = jest.fn();
render(
<Dropdown onSelect={onSelect} toggle={(toggleRef) => toggle(toggleRef)}>
<Dropdown isOpen onSelect={onSelect} toggle={(toggleRef) => toggle(toggleRef)}>
{dropdownChildren}
</Dropdown>
);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,40 +2,62 @@

exports[`match snapshot 1`] = `
<DocumentFragment>
<div>
<div
data-testid="mock-wrapper"
>
<div
class="customClass"
data-ouia-component-id="dropdown"
data-ouia-component-type="PF5/Dropdown"
data-ouia-safe="true"
data-testid="menu-mock"
data-testid="popper"
>
<div>
<div
class="customClass"
data-ouia-component-id="dropdown"
data-ouia-component-type="PF5/Dropdown"
data-ouia-safe="true"
data-testid="menu-mock"
>
<div>
Dropdown children
<div>
Dropdown children
</div>
</div>
</div>
<div>
Mock item
</div>
<p>
isPlain: true
</p>
<p>
isScrollable: true
</p>
<p>
minWidth: undefined
</p>
</div>
<div>
Mock item
</div>
<p>
isPlain: true
zIndex: 9999
</p>
<p>
isVisible: true
</p>
<p>
enableFlip: undefined
</p>
<p>
isScrollable: true
placement: undefined
</p>
<p>
appendTo: undefined
</p>
<p>
distance: undefined
</p>
<p>
flipBehavior: undefined
</p>
<p>
minWidth: undefined
</p>
</div>
<p>
zIndex: 9999
</p>
<p>
isOpen: true
</p>
<div>
<button>
Dropdown
</button>
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

This file was deleted.

Loading

0 comments on commit 20e3c8f

Please sign in to comment.