Skip to content

Commit

Permalink
Add test cases for enter/space key interactions
Browse files Browse the repository at this point in the history
  • Loading branch information
aaronccasanova committed Mar 27, 2024
1 parent 2185140 commit d1618f8
Showing 1 changed file with 32 additions and 0 deletions.
32 changes: 32 additions & 0 deletions polaris-react/src/components/Tooltip/tests/Tooltip.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,38 @@ describe('<Tooltip />', () => {
});
});

it('closes itself when enter is pressed on keyup', () => {
const tooltip = mountWithApp(
<Tooltip active content="This order has shipping labels.">
<div>Order #1001</div>
</Tooltip>,
);

findWrapperComponent(tooltip)!.trigger('onKeyUp', {
key: 'Enter',
});

expect(tooltip).toContainReactComponent(TooltipOverlay, {
active: false,
});
});

it('closes itself when space is pressed on keyup', () => {
const tooltip = mountWithApp(
<Tooltip active content="This order has shipping labels.">
<div>Order #1001</div>
</Tooltip>,
);

findWrapperComponent(tooltip)!.trigger('onKeyUp', {
key: ' ',
});

expect(tooltip).toContainReactComponent(TooltipOverlay, {
active: false,
});
});

it('does not call onOpen when initially activated', () => {
const openSpy = jest.fn();
const tooltip = mountWithApp(
Expand Down

0 comments on commit d1618f8

Please sign in to comment.