Skip to content

Commit

Permalink
Add more unit test
Browse files Browse the repository at this point in the history
Signed-off-by: gaobinlong <gbinlong@amazon.com>
  • Loading branch information
gaobinlong committed Mar 21, 2024
1 parent b26a754 commit 8a2a5cb
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -191,4 +191,21 @@ describe('WorkspaceUpdater', () => {
});
expect(notificationToastsAddSuccess).not.toHaveBeenCalled();
});

it('should show danger toasts after update workspace threw error', async () => {
workspaceClientUpdate.mockImplementation(() => {
throw new Error('update workspace failed');
});
const { getByTestId } = render(<WorkspaceUpdater />);
const nameInput = getByTestId('workspaceForm-workspaceDetails-nameInputText');
fireEvent.input(nameInput, {
target: { value: 'test workspace name' },
});
fireEvent.click(getByTestId('workspaceForm-bottomBar-updateButton'));
expect(workspaceClientUpdate).toHaveBeenCalled();
await waitFor(() => {
expect(notificationToastsAddDanger).toHaveBeenCalled();
});
expect(notificationToastsAddSuccess).not.toHaveBeenCalled();
});
});

0 comments on commit 8a2a5cb

Please sign in to comment.