Skip to content

Commit 05d2032

Browse files
committed
Create test for Action snapshots onClick
1 parent 5fa990e commit 05d2032

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

src/app/__tests__/action.test.tsx

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { render, screen, fireEvent } from '@testing-library/react';
33
import user from '@testing-library/user-event';
44
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
55
import Action from '../components/Action';
6+
import { changeView } from '../actions/actions';
67

78
// @ts-ignore
89
Action.cleanTime = jest.fn().mockReturnValue();
@@ -82,5 +83,11 @@ describe('unit testing for Action.tsx', () => {
8283
fireEvent.keyDown(screen.getByRole('presentation'), {key: 'Enter', code: 'Enter', charCode: 13});
8384
expect(props.handleOnkeyDown).toHaveBeenCalled();;
8485
});
86+
87+
test('Clicking the snapshot should trigger onClick', () => {
88+
render(<Action {...props} />);
89+
fireEvent.click(screen.getByRole('presentation'));
90+
expect(props.dispatch).toHaveBeenCalledWith(changeView(2));;
91+
});
8592
});
8693
});

0 commit comments

Comments
 (0)