Skip to content

Commit

Permalink
Improve code coverage #18
Browse files Browse the repository at this point in the history
  • Loading branch information
joelvdavies committed Nov 1, 2023
1 parent f8fa688 commit ea31ee0
Show file tree
Hide file tree
Showing 2 changed files with 53 additions and 1 deletion.
12 changes: 12 additions & 0 deletions src/systems/systemDetails.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ describe('SystemDetails', () => {

createView();

expect(screen.getByText('No system selected')).toBeInTheDocument();
expect(screen.getByText('Please select a system')).toBeInTheDocument();
});

Expand Down Expand Up @@ -64,4 +65,15 @@ describe('SystemDetails', () => {
// One for each of location, owner and description
expect(await screen.findAllByText('None')).toHaveLength(3);
});

it('renders correctly when the system is not found', async () => {
props.id = 'invalid_id';

createView();

await waitFor(() => {
expect(screen.getByText('No system selected')).toBeInTheDocument();
});
expect(screen.getByText('Please select a system')).toBeInTheDocument();
});
});
42 changes: 41 additions & 1 deletion src/systems/systems.component.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,47 @@ describe('Systems', () => {
expect(screen.getByText('Smaller laser')).toBeInTheDocument();
});

it('navigates back to the root directory when home button clicked', async () => {
it('renders the breadcrumbs when navigating to a subsystem', async () => {
createView('/inventory-management-system/systems');

await waitFor(() => {
expect(
screen.getByRole('link', { name: 'Giant laser' })
).toBeInTheDocument();
});
await user.click(screen.getByRole('link', { name: 'Giant laser' }));

await waitFor(() => {
expect(screen.getByText('Smaller laser')).toBeInTheDocument();
});
expect(
screen.queryByRole('link', { name: 'motion' })
).not.toBeInTheDocument();
});

it('navigates back a system using the breadcrumbs', async () => {
createView('/inventory-management-system/systems/65328f34a40ff5301575a4e4');

await waitFor(() => {
expect(screen.getByText('Smaller laser')).toBeInTheDocument();
});

await user.click(
screen.getByRole('link', {
name: 'Giant laser',
})
);
await waitFor(() => {
expect(
screen.queryByRole('link', {
name: 'Giant laser',
})
).not.toBeInTheDocument();
});
expect(screen.getByText('Smaller laser')).toBeInTheDocument();
});

it('navigates back to the root systems when home button clicked', async () => {
createView('/inventory-management-system/systems/65328f34a40ff5301575a4e3');

await waitFor(() => {
Expand Down

0 comments on commit ea31ee0

Please sign in to comment.