Skip to content

Commit 8cab1e9

Browse files
feat: update tests
1 parent e6eab50 commit 8cab1e9

File tree

4 files changed

+9
-8
lines changed

4 files changed

+9
-8
lines changed

src/courseware/course/sequence/sequence-navigation/SequenceNavigation.test.jsx

+1-1
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ describe('Sequence Navigation', () => {
7676
const onNavigate = jest.fn();
7777
render(<SequenceNavigation {...mockData} {...{ onNavigate }} />, { wrapWithRouter: true });
7878

79-
const unitButtons = screen.getAllByRole('link', { name: /\d+/ });
79+
const unitButtons = screen.getAllByRole('tabpanel', { name: /\d+/ });
8080
expect(unitButtons).toHaveLength(unitButtons.length);
8181
unitButtons.forEach(button => fireEvent.click(button));
8282
expect(onNavigate).toHaveBeenCalledTimes(unitButtons.length);

src/courseware/course/sequence/sequence-navigation/SequenceNavigationTabs.test.jsx

+2-2
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ describe('Sequence Navigation Tabs', () => {
4343
useIndexOfLastVisibleChild.mockReturnValue([0, null, null]);
4444
render(<SequenceNavigationTabs {...mockData} />, { wrapWithRouter: true });
4545

46-
expect(screen.getAllByRole('link')).toHaveLength(unitBlocks.length);
46+
expect(screen.getAllByRole('tabpanel')).toHaveLength(unitBlocks.length);
4747
});
4848

4949
it('renders unit buttons and dropdown button', async () => {
@@ -60,7 +60,7 @@ describe('Sequence Navigation Tabs', () => {
6060
await fireEvent.click(dropdownToggle);
6161
});
6262
const dropdownMenu = container.querySelector('.dropdown');
63-
const dropdownButtons = getAllByRole(dropdownMenu, 'link');
63+
const dropdownButtons = getAllByRole(dropdownMenu, 'tabpanel');
6464
expect(dropdownButtons).toHaveLength(unitBlocks.length);
6565
expect(screen.getByRole('button', { name: `${activeBlockNumber} of ${unitBlocks.length}` }))
6666
.toHaveClass('dropdown-toggle');

src/courseware/course/sequence/sequence-navigation/UnitButton.jsx

+1
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,7 @@ const UnitButton = ({
7575
{bookmarked ? (
7676
<BookmarkFilledIcon
7777
className="unit-filled-bookmark text-primary small position-absolute"
78+
data-testid="bookmark-icon"
7879
style={{
7980
top: '-3px', right: '2px', height: '20px', width: '20px',
8081
}}

src/courseware/course/sequence/sequence-navigation/UnitButton.test.jsx

+5-5
Original file line numberDiff line numberDiff line change
@@ -34,24 +34,24 @@ describe('Unit Button', () => {
3434

3535
it('hides title by default', () => {
3636
render(<UnitButton {...mockData} />, { wrapWithRouter: true });
37-
expect(screen.getByRole('link')).not.toHaveTextContent(unit.display_name);
37+
expect(screen.getByRole('tabpanel')).not.toHaveTextContent(unit.display_name);
3838
});
3939

4040
it('shows title', () => {
41-
render(<UnitButton {...mockData} showTitle />);
41+
render(<UnitButton {...mockData} showTitle />, { wrapWithRouter: true });
4242
expect(screen.getByRole('tabpanel')).toHaveTextContent(unit.display_name);
4343
});
4444

4545
it('check button attributes', () => {
46-
render(<UnitButton {...mockData} showTitle />);
46+
render(<UnitButton {...mockData} showTitle />, { wrapWithRouter: true });
4747
expect(screen.getByRole('tabpanel')).toHaveAttribute('id', `${unit.display_name}-${courseMetadata.id}`);
4848
expect(screen.getByRole('tabpanel')).toHaveAttribute('aria-controls', unit.display_name);
4949
expect(screen.getByRole('tabpanel')).toHaveAttribute('aria-labelledby', unit.display_name);
5050
expect(screen.getByRole('tabpanel')).toHaveAttribute('tabindex', '-1');
5151
});
5252

5353
it('button with isActive prop has tabindex 0', () => {
54-
render(<UnitButton {...mockData} isActive />);
54+
render(<UnitButton {...mockData} isActive />, { wrapWithRouter: true });
5555
expect(screen.getByRole('tabpanel')).toHaveAttribute('tabindex', '0');
5656
});
5757

@@ -93,7 +93,7 @@ describe('Unit Button', () => {
9393
it('handles the click', () => {
9494
const onClick = jest.fn();
9595
render(<UnitButton {...mockData} onClick={onClick} />, { wrapWithRouter: true });
96-
fireEvent.click(screen.getByRole('link'));
96+
fireEvent.click(screen.getByRole('tabpanel'));
9797
expect(onClick).toHaveBeenCalledTimes(1);
9898
});
9999
});

0 commit comments

Comments
 (0)