Skip to content

Commit

Permalink
additional test coverage
Browse files Browse the repository at this point in the history
  • Loading branch information
zburke committed Jun 26, 2024
1 parent 45e5f8c commit 253227c
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 7 deletions.
42 changes: 35 additions & 7 deletions src/RootWithIntl.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,26 @@ import { render, screen } from '@folio/jest-config-stripes/testing-library/react
import { Router as DefaultRouter } from 'react-router-dom';
import { createMemoryHistory } from 'history';

import Login from './components/Login';
import MainNav from './components/MainNav';
import MainContainer from './components/MainContainer';
import ModuleContainer from './components/ModuleContainer';
import {
Login,
MainNav,
MainContainer,
ModuleContainer,
OverlayContainer,
StaleBundleWarning,
SessionEventContainer,
} from './components';

import RootWithIntl from './RootWithIntl';
import Stripes from './Stripes';

jest.mock('./components/Login', () => () => '<Login>');
jest.mock('./components/MainNav', () => () => '<MainNav>');
jest.mock('./components/ModuleContainer', () => () => '<ModuleContainer>');
jest.mock('./components/OverlayContainer', () => () => '<OverlayContainer>');
jest.mock('./components/ModuleContainer', () => ({ children }) => children);
jest.mock('./components/MainContainer', () => ({ children }) => children);
jest.mock('./components/StaleBundleWarning', () => () => '<StaleBundleWarning>');
jest.mock('./components/SessionEventContainer', () => () => '<SessionEventContainer>');

const defaultHistory = createMemoryHistory();

Expand Down Expand Up @@ -82,14 +91,33 @@ describe('RootWithIntl', () => {
const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, discovery: { isFinished: true } });
await render(<Harness><RootWithIntl stripes={stripes} history={defaultHistory} isAuthenticated /></Harness>);

expect(screen.getByText(/<ModuleContainer>/)).toBeInTheDocument();
expect(screen.queryByText(/<Login>/)).toBeNull();
expect(screen.queryByText(/<MainNav>/)).toBeInTheDocument();
expect(screen.getByText(/<OverlayContainer>/)).toBeInTheDocument();
});

it('if discovery is finished', async () => {
const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: {}, store, okapi: {}, discovery: { isFinished: true } });
await render(<Harness><RootWithIntl stripes={stripes} history={defaultHistory} isAuthenticated /></Harness>);

expect(screen.getByText(/<ModuleContainer>/)).toBeInTheDocument();
expect(screen.queryByText(/<Login>/)).toBeNull();
expect(screen.queryByText(/<MainNav>/)).toBeInTheDocument();
expect(screen.getByText(/<OverlayContainer>/)).toBeInTheDocument();
});
});

it('renders StaleBundleWarning', async () => {
const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: { staleBundleWarning: {} }, store, okapi: {}, discovery: { isFinished: true } });
await render(<Harness><RootWithIntl stripes={stripes} history={defaultHistory} isAuthenticated /></Harness>);

expect(screen.getByText(/<StaleBundleWarning>/)).toBeInTheDocument();
});

it('renders SessionEventContainer', async () => {
const stripes = new Stripes({ epics: {}, logger: {}, bindings: {}, config: { useSecureTokens: true }, store, okapi: {}, discovery: { isFinished: true } });
await render(<Harness><RootWithIntl stripes={stripes} history={defaultHistory} isAuthenticated /></Harness>);

expect(screen.getByText(/<SessionEventContainer>/)).toBeInTheDocument();
});

Check failure on line 121 in src/RootWithIntl.test.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Block must not be padded by blank lines

Check failure on line 121 in src/RootWithIntl.test.js

View workflow job for this annotation

GitHub Actions / ui / Install and lint / Install and lint

Block must not be padded by blank lines

});
1 change: 1 addition & 0 deletions src/components/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ export { default as BadRequestScreen } from './BadRequestScreen';
export { default as NoPermissionScreen } from './NoPermissionScreen';
export { default as ResetPasswordNotAvailableScreen } from './ResetPasswordNotAvailableScreen';
export { default as SessionEventContainer } from './SessionEventContainer';
export { default as StaleBundleWarning } from './StaleBundleWarning';

export * from './ModuleHierarchy';
export * from './Namespace';

0 comments on commit 253227c

Please sign in to comment.