Skip to content

Commit a63321c

Browse files
committed
test: refactor: userEvent instead of fireEvent
1 parent 0cd5044 commit a63321c

1 file changed

Lines changed: 5 additions & 5 deletions

File tree

src/library-authoring/create-legacy-library/CreateLegacyLibrary.test.tsx

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@ import type MockAdapter from 'axios-mock-adapter';
33
import userEvent from '@testing-library/user-event';
44

55
import {
6-
fireEvent,
76
initializeMocks,
87
render,
98
screen,
@@ -72,7 +71,7 @@ describe('<CreateLegacyLibrary />', () => {
7271
await user.click(slugInput);
7372
await user.type(slugInput, 'test_library_slug');
7473

75-
fireEvent.click(await screen.findByRole('button', { name: /create/i }));
74+
await user.click(await screen.findByRole('button', { name: /create/i }));
7675
await waitFor(() => {
7776
expect(axiosMock.history.post.length).toBe(1);
7877
expect(axiosMock.history.post[0].data).toBe(
@@ -111,7 +110,7 @@ describe('<CreateLegacyLibrary />', () => {
111110
await user.click(slugInput);
112111
await user.type(slugInput, 'test_library_slug');
113112

114-
fireEvent.click(await screen.findByRole('button', { name: /create/i }));
113+
await user.click(await screen.findByRole('button', { name: /create/i }));
115114
await waitFor(() => {
116115
expect(axiosMock.history.post.length).toBe(0);
117116
});
@@ -149,7 +148,7 @@ describe('<CreateLegacyLibrary />', () => {
149148
await user.click(slugInput);
150149
await user.type(slugInput, 'test_library_slug');
151150

152-
fireEvent.click(await screen.findByRole('button', { name: /create/i }));
151+
await user.click(await screen.findByRole('button', { name: /create/i }));
153152
await waitFor(() => {
154153
expect(axiosMock.history.post.length).toBe(1);
155154
expect(axiosMock.history.post[0].data).toBe(
@@ -192,9 +191,10 @@ describe('<CreateLegacyLibrary />', () => {
192191
});
193192

194193
test('cancel creating library navigates to libraries page', async () => {
194+
const user = userEvent.setup();
195195
render(<CreateLegacyLibrary />);
196196

197-
fireEvent.click(await screen.findByRole('button', { name: /cancel/i }));
197+
await user.click(await screen.findByRole('button', { name: /cancel/i }));
198198
await waitFor(() => {
199199
expect(mockNavigate).toHaveBeenCalledWith('/libraries-v1');
200200
});

0 commit comments

Comments
 (0)