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 7b69d9d commit 007042f
Showing 1 changed file with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -219,4 +219,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 007042f

Please sign in to comment.