[TNL-7268] Fix tests after rebase
This commit is contained in:
@@ -21,18 +21,19 @@ describe('Sequence', () => {
|
||||
|
||||
it('renders correctly without data', () => {
|
||||
render(<Sequence {...mockData} {...{ unitId: undefined, sequenceId: undefined }} />, { initialState: {} });
|
||||
expect(screen.getByText('Loading learning sequence...')).toBeInTheDocument();
|
||||
expect(screen.getByText('There is no content here.')).toBeInTheDocument();
|
||||
expect(screen.queryByRole('button')).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('renders correctly for gated content', async () => {
|
||||
render(<Sequence {...mockData} {...{ sequenceId: '3' }} />);
|
||||
const { container } = render(<Sequence {...mockData} {...{ sequenceId: '3' }} />);
|
||||
expect(screen.getByText('Loading locked content messaging...')).toBeInTheDocument();
|
||||
// Only `Previous`, `Next` and `Bookmark` buttons.
|
||||
expect(screen.getAllByRole('button').length).toEqual(3);
|
||||
|
||||
expect(await screen.findByText('Content Locked')).toBeInTheDocument();
|
||||
expect(screen.getByAltText('fa-lock')).toBeInTheDocument();
|
||||
const unitContainer = container.querySelector('.unit-container');
|
||||
expect(unitContainer.querySelector('svg')).toHaveClass('fa-lock');
|
||||
expect(screen.getByText(/You must complete the prerequisite/)).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Go To Prerequisite Section' })).toBeInTheDocument();
|
||||
expect(screen.queryByText('Loading locked content messaging...')).not.toBeInTheDocument();
|
||||
|
||||
@@ -18,13 +18,13 @@ describe('Sequence Content', () => {
|
||||
});
|
||||
|
||||
it('displays messages for the locked content', async () => {
|
||||
render(<SequenceContent {...mockData} gated />, { initialState });
|
||||
const { container } = render(<SequenceContent {...mockData} gated />, { initialState });
|
||||
expect(screen.getByText('Loading locked content messaging...')).toBeInTheDocument();
|
||||
|
||||
expect(await screen.findByText('Content Locked')).toBeInTheDocument();
|
||||
expect(screen.getByText('test-sequence')).toBeInTheDocument();
|
||||
expect(screen.queryByText('Loading locked content messaging...')).not.toBeInTheDocument();
|
||||
expect(screen.getByAltText('fa-lock')).toBeInTheDocument();
|
||||
expect(container.querySelector('svg')).toHaveClass('fa-lock');
|
||||
expect(screen.getByText(/You must complete the prerequisite/)).toBeInTheDocument();
|
||||
expect(screen.getByRole('button', { name: 'Go To Prerequisite Section' })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
@@ -36,28 +36,38 @@ describe('Unit Button', () => {
|
||||
});
|
||||
|
||||
it('does not show completion for non-completed unit', () => {
|
||||
render(<UnitButton {...mockData} />, { initialState });
|
||||
expect(screen.queryByAltText('fa-check')).toBeNull();
|
||||
const { container } = render(<UnitButton {...mockData} />, { initialState });
|
||||
container.querySelectorAll('svg').forEach(icon => {
|
||||
expect(icon).not.toHaveClass('fa-check');
|
||||
});
|
||||
});
|
||||
|
||||
it('shows completion for completed unit', () => {
|
||||
render(<UnitButton {...mockData} unitId="problem" />, { initialState });
|
||||
expect(screen.getByAltText('fa-check')).toBeInTheDocument();
|
||||
const { container } = render(<UnitButton {...mockData} unitId="problem" />, { initialState });
|
||||
const buttonIcons = container.querySelectorAll('svg');
|
||||
expect(buttonIcons).toHaveLength(3);
|
||||
expect(buttonIcons[1]).toHaveClass('fa-check');
|
||||
});
|
||||
|
||||
it('hides completion', () => {
|
||||
render(<UnitButton {...mockData} unitId="problem" showCompletion={false} />, { initialState });
|
||||
expect(screen.queryByAltText('fa-check')).toBeNull();
|
||||
const { container } = render(<UnitButton {...mockData} unitId="problem" showCompletion={false} />, { initialState });
|
||||
container.querySelectorAll('svg').forEach(icon => {
|
||||
expect(icon).not.toHaveClass('fa-check');
|
||||
});
|
||||
});
|
||||
|
||||
it('does not show bookmark', () => {
|
||||
render(<UnitButton {...mockData} />, { initialState });
|
||||
expect(screen.queryByAltText('fa-bookmark')).toBeNull();
|
||||
const { container } = render(<UnitButton {...mockData} />, { initialState });
|
||||
container.querySelectorAll('svg').forEach(icon => {
|
||||
expect(icon).not.toHaveClass('fa-bookmark');
|
||||
});
|
||||
});
|
||||
|
||||
it('shows bookmark', () => {
|
||||
render(<UnitButton {...mockData} unitId="problem" />, { initialState });
|
||||
expect(screen.getByAltText('fa-bookmark')).toBeInTheDocument();
|
||||
const { container } = render(<UnitButton {...mockData} unitId="problem" />, { initialState });
|
||||
const buttonIcons = container.querySelectorAll('svg');
|
||||
expect(buttonIcons).toHaveLength(3);
|
||||
expect(buttonIcons[2]).toHaveClass('fa-bookmark');
|
||||
});
|
||||
|
||||
it('handles the click', () => {
|
||||
|
||||
Reference in New Issue
Block a user