Skip to content

Commit

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

it('should show danger toasts when currentWorkspace is missing after click update button', async () => {
const mockedWorkspacesService = workspacesServiceMock.createSetupContract();
const { getByTestId } = render(<WorkspaceUpdater workspaceService={mockedWorkspacesService} />);

const nameInput = getByTestId('workspaceForm-workspaceDetails-nameInputText');
fireEvent.input(nameInput, {
target: { value: 'test workspace name' },
});
fireEvent.click(getByTestId('workspaceForm-bottomBar-updateButton'));
mockedWorkspacesService.currentWorkspace$ = new BehaviorSubject<WorkspaceObject | null>(null);
expect(workspaceClientUpdate).toHaveBeenCalled();
await waitFor(() => {
expect(notificationToastsAddDanger).toHaveBeenCalled();
});
expect(notificationToastsAddSuccess).not.toHaveBeenCalled();
});
});

0 comments on commit 64a9e5f

Please sign in to comment.