Skip to content

Commit

Permalink
Remove loop
Browse files Browse the repository at this point in the history
  • Loading branch information
cnasikas committed Jan 15, 2024
1 parent 63f5870 commit f47d60f
Showing 1 changed file with 40 additions and 42 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -71,65 +71,63 @@ describe('CaseViewPage', () => {
appMockRenderer = createAppMockRenderer();
});

for (let index = 0; index < 100; index++) {
it('shows the header section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);
it('shows the header section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);

expect(await screen.findByTestId('test-case-view-header')).toBeInTheDocument();
});
expect(await screen.findByTestId('test-case-view-header')).toBeInTheDocument();
});

it('shows the metrics section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);
it('shows the metrics section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);

expect(await screen.findByTestId('test-case-view-metrics')).toBeInTheDocument();
});
expect(await screen.findByTestId('test-case-view-metrics')).toBeInTheDocument();
});

it('shows the activity section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);
it('shows the activity section', async () => {
appMockRenderer.render(<CaseViewPage {...caseProps} />);

expect(await screen.findByTestId('test-case-view-activity')).toBeInTheDocument();
});
expect(await screen.findByTestId('test-case-view-activity')).toBeInTheDocument();
});

it('should set the breadcrumbs correctly', async () => {
const onComponentInitialized = jest.fn();
it('should set the breadcrumbs correctly', async () => {
const onComponentInitialized = jest.fn();

appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);
appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);

await waitFor(() => {
expect(useCasesTitleBreadcrumbsMock).toHaveBeenCalledWith(caseProps.caseData.title);
});
await waitFor(() => {
expect(useCasesTitleBreadcrumbsMock).toHaveBeenCalledWith(caseProps.caseData.title);
});
});

it('should call onComponentInitialized on mount', async () => {
const onComponentInitialized = jest.fn();
it('should call onComponentInitialized on mount', async () => {
const onComponentInitialized = jest.fn();

appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);
appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);

await waitFor(() => {
expect(onComponentInitialized).toHaveBeenCalled();
});
await waitFor(() => {
expect(onComponentInitialized).toHaveBeenCalled();
});
});

it('should call onComponentInitialized only once', async () => {
const onComponentInitialized = jest.fn();
it('should call onComponentInitialized only once', async () => {
const onComponentInitialized = jest.fn();

const { rerender } = appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);
const { rerender } = appMockRenderer.render(
<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />
);

await waitFor(() => {
expect(onComponentInitialized).toHaveBeenCalled();
});
await waitFor(() => {
expect(onComponentInitialized).toHaveBeenCalled();
});

rerender(<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />);
rerender(<CaseViewPage {...caseProps} onComponentInitialized={onComponentInitialized} />);

await waitForComponentToUpdate();
await waitForComponentToUpdate();

expect(onComponentInitialized).toBeCalledTimes(1);
});
}
expect(onComponentInitialized).toBeCalledTimes(1);
});
});

0 comments on commit f47d60f

Please sign in to comment.