Skip to content

Commit

Permalink
update unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
XavierM committed Jul 17, 2020
1 parent 2b5fe0d commit 3339c80
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -157,8 +157,10 @@ describe('AddFilterToGlobalSearchBar Component', () => {
</TestProviders>
);

wrapper.find('[data-test-subj="withHoverActionsButton"]').simulate('mouseenter');
wrapper.update();

wrapper
.simulate('mouseenter')
.find('[data-test-subj="hover-actions-container"] [data-euiicon-type]')
.first()
.simulate('click');
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ describe('DraggableWrapper', () => {
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(false);
});

test('it renders hover actions when the mouse is over the draggable wrapper', () => {
test('it renders hover actions when the mouse is over the text of draggable wrapper', () => {
const wrapper = mount(
<TestProviders>
<MockedProvider mocks={mocksSource} addTypename={false}>
Expand All @@ -76,7 +76,7 @@ describe('DraggableWrapper', () => {
</TestProviders>
);

wrapper.simulate('mouseenter');
wrapper.find('[data-test-subj="withHoverActionsButton"]').simulate('mouseenter');
wrapper.update();
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,11 @@ export const WithHoverActions = React.memo<Props>(
}, []);

const content = useMemo(
() => <div onMouseEnter={onMouseEnter}>{render(showHoverContent)}</div>,
() => (
<div data-test-subj="withHoverActionsButton" onMouseEnter={onMouseEnter}>
{render(showHoverContent)}
</div>
),
[onMouseEnter, render, showHoverContent]
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ describe('FieldName', () => {
<FieldName {...defaultProps} />
</TestProviders>
);
wrapper.find('div').at(1).simulate('mouseenter');
wrapper.find('[data-test-subj="withHoverActionsButton"]').at(0).simulate('mouseenter');
wrapper.update();
expect(wrapper.find('[data-test-subj="copy-to-clipboard"]').exists()).toBe(true);
});
Expand Down

0 comments on commit 3339c80

Please sign in to comment.