Skip to content

Commit

Permalink
fix(Release): add unit tests for overview tab and snapshot details view
Browse files Browse the repository at this point in the history
  • Loading branch information
sahil143 committed Nov 27, 2024
1 parent c91faa2 commit a5429d6
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/components/Releases/__tests__/ReleaseOverviewTab.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -19,13 +19,18 @@ jest.mock('../../../hooks/useReleases', () => ({
const watchResourceMock = createK8sWatchResourceMock();

describe('ReleaseOverviewTab', () => {
beforeEach(() => {
watchResourceMock.mockReturnValue([{ spec: { application: 'test-app' } }, true]);
});
beforeEach(() => {});

createUseWorkspaceInfoMock({ namespace: 'test-ns', workspace: 'test-ws' });

it('should render loading indicator', () => {
watchResourceMock.mockReturnValue([{ spec: { application: 'test-app' } }, false]);
render(<ReleaseOverviewTab />);
expect(screen.getByRole('progressbar')).toBeVisible();
});

it('should render correct details', () => {
watchResourceMock.mockReturnValue([{ spec: { application: 'test-app' } }, true]);
render(<ReleaseOverviewTab />);
expect(screen.getByText('Duration')).toBeVisible();
expect(screen.getByText('10 seconds')).toBeVisible();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,12 @@ describe('SnapshotDetailsView', () => {
(useCommitStatus as jest.Mock).mockReturnValueOnce(['-', true]);
});

it('should render loading indicator', () => {
watchResourceMock.mockReturnValue([[], false]);
renderWithQueryClientAndRouter(<SnapshotDetails />);
screen.getByRole('progressbar');
});

it('should show error state if test cannot be loaded', () => {
watchResourceMock.mockReturnValue([
[],
Expand Down

0 comments on commit a5429d6

Please sign in to comment.