Skip to content

Commit

Permalink
updated tests
Browse files Browse the repository at this point in the history
  • Loading branch information
anishagg17 committed Mar 16, 2020
1 parent b6d4736 commit ab84c3c
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 31 deletions.
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
## [`master`](https://github.com/elastic/eui/tree/master)

- Removed `EuiKeyPadMenuItemButton` in favor of just `EuiKeyPadMenuItem` that can also accept an `onClick` ([#3062](https://github.com/elastic/eui/pull/3062))
- Added props descriptions for `EuiComboBox` ([#3007](https://github.com/elastic/eui/pull/3007))
- Exported `dateFormatAliases` as a part of the public API ([#3043](https://github.com/elastic/eui/pull/3043))
- Exported `EuiTextProps` type definition ([#3039](https://github.com/elastic/eui/pull/3039))
Expand All @@ -13,6 +12,10 @@
- Added `useResizeObserver` hook ([#2991](https://github.com/elastic/eui/pull/2991))
- Added `showColumnSelector.allowHide` and `showColumnSelector.allowReorder` props to `EuiDataGrid` UI configuration ([#2993](https://github.com/elastic/eui/pull/2993))

**Breaking changes**

- Removed `EuiKeyPadMenuItemButton` in favor of just `EuiKeyPadMenuItem` that can also accept an `onClick` ([#3062](https://github.com/elastic/eui/pull/3062))

**Bug Fixes**

- Fixed `EuiFieldNumber` so values of type `number` are now allowed ([#3020](https://github.com/elastic/eui/pull/3020))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,9 @@ exports[`EuiKeyPadMenuItem is rendered 1`] = `
</a>
`;

exports[`EuiKeyPadMenuItem renders href 1`] = `
exports[`EuiKeyPadMenuItem renders button 1`] = `
<a
class="euiKeyPadMenuItem"
href="#"
role="menuitem"
>
<div
Expand All @@ -47,11 +46,10 @@ exports[`EuiKeyPadMenuItem renders href 1`] = `
</a>
`;

exports[`EuiKeyPadMenuItemButton is rendered 1`] = `
exports[`EuiKeyPadMenuItem renders href 1`] = `
<a
aria-label="aria-label"
class="euiKeyPadMenuItem testClass1 testClass2"
data-test-subj="test subject string"
class="euiKeyPadMenuItem"
href="#"
role="menuitem"
>
<div
Expand Down
46 changes: 22 additions & 24 deletions src/components/key_pad_menu/key_pad_menu_item.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,42 @@ describe('EuiKeyPadMenuItem', () => {

expect(component).toMatchSnapshot();
});
});

describe('EuiKeyPadMenuItemButton', () => {
test('is rendered', () => {
test('renders button', () => {
const onClickHandler = jest.fn();

const component = render(
<EuiKeyPadMenuItem label="Label" {...requiredProps}>
<EuiKeyPadMenuItem label="Label" onClick={onClickHandler}>
Icon
</EuiKeyPadMenuItem>
);

expect(component).toMatchSnapshot();
});

describe('onClick', () => {
test("isn't called upon instantiation", () => {
const onClickHandler = jest.fn();
test("onClick isn't called upon instantiation", () => {
const onClickHandler = jest.fn();

shallow(
<EuiKeyPadMenuItem label="Label" onClick={onClickHandler}>
Icon
</EuiKeyPadMenuItem>
);
shallow(
<EuiKeyPadMenuItem label="Label" onClick={onClickHandler}>
Icon
</EuiKeyPadMenuItem>
);

expect(onClickHandler).not.toBeCalled();
});
expect(onClickHandler).not.toBeCalled();
});

test('is called when the button is clicked', () => {
const onClickHandler = jest.fn();
test('onClick is called when the button is clicked', () => {
const onClickHandler = jest.fn();

const $button = shallow(
<EuiKeyPadMenuItem label="Label" onClick={onClickHandler}>
Icon
</EuiKeyPadMenuItem>
);
const $button = shallow(
<EuiKeyPadMenuItem label="Label" onClick={onClickHandler}>
Icon
</EuiKeyPadMenuItem>
);

$button.simulate('click');
$button.simulate('click');

expect(onClickHandler).toBeCalledTimes(1);
});
expect(onClickHandler).toBeCalledTimes(1);
});
});

0 comments on commit ab84c3c

Please sign in to comment.