Skip to content

Commit

Permalink
fix unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
angorayc committed Jul 9, 2020
1 parent 0fd7c3d commit 65db38e
Showing 1 changed file with 39 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import { DEFAULT_ACTIONS_COLUMN_WIDTH } from '../constants';
import * as i18n from '../translations';

import { Actions } from '.';
import { TimelineType } from '../../../../../../common/types/timeline';

jest.mock('react-redux', () => {
const origin = jest.requireActual('react-redux');
Expand Down Expand Up @@ -203,7 +204,7 @@ describe('Actions', () => {
expect(toggleShowNotes).toBeCalled();
});

test('it renders correct tooltip for NotesButton', () => {
test('it renders correct tooltip for NotesButton - timeline', () => {
const toggleShowNotes = jest.fn();

const wrapper = mount(
Expand Down Expand Up @@ -233,6 +234,43 @@ describe('Actions', () => {
expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(i18n.NOTES_TOOLTIP);
});

test('it renders correct tooltip for NotesButton - timeline template', () => {
(useSelector as jest.Mock).mockReturnValue({
...mockTimelineModel,
timelineType: TimelineType.template,
});
const toggleShowNotes = jest.fn();

const wrapper = mount(
<TestProviders>
<Actions
actionsColumnWidth={DEFAULT_ACTIONS_COLUMN_WIDTH}
associateNote={jest.fn()}
checked={false}
expanded={false}
eventId="abc"
eventIsPinned={false}
getNotesByIds={jest.fn()}
loading={false}
loadingEventIds={[]}
noteIds={[]}
onEventToggled={jest.fn()}
onPinClicked={jest.fn()}
onRowSelected={jest.fn()}
showCheckboxes={false}
showNotes={false}
toggleShowNotes={toggleShowNotes}
updateNote={jest.fn()}
/>
</TestProviders>
);

expect(wrapper.find('[data-test-subj="add-note"]').prop('toolTip')).toEqual(
i18n.NOTES_DISABLE_TOOLTIP
);
(useSelector as jest.Mock).mockReturnValue(mockTimelineModel);
});

test('it does NOT render a pin button when isEventViewer is true', () => {
const onPinClicked = jest.fn();

Expand Down

0 comments on commit 65db38e

Please sign in to comment.