forked from openedx/frontend-app-authoring
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCourseImportHomePage.test.tsx
More file actions
56 lines (49 loc) · 1.76 KB
/
CourseImportHomePage.test.tsx
File metadata and controls
56 lines (49 loc) · 1.76 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
import {
initializeMocks,
render as testRender,
screen,
} from '@src/testUtils';
import { LibraryProvider } from '../common/context/LibraryContext';
import {
mockContentLibrary,
mockGetCourseImports,
} from '../data/api.mocks';
import { CourseImportHomePage } from './CourseImportHomePage';
mockContentLibrary.applyMock();
mockGetCourseImports.applyMock();
const mockNavigate = jest.fn();
jest.mock('react-router-dom', () => ({
...jest.requireActual('react-router-dom'),
useNavigate: () => mockNavigate,
}));
const render = (libraryId: string) => (
testRender(
<CourseImportHomePage />,
{
extraWrapper: ({ children }: { children: React.ReactNode }) => (
<LibraryProvider libraryId={libraryId}>
{children}
</LibraryProvider>
),
path: '/libraries/:libraryId/import',
params: { libraryId },
},
)
);
describe('<CourseImportHomePage>', () => {
beforeEach(() => {
initializeMocks();
});
it('should render the library course import home page', async () => {
render(mockGetCourseImports.libraryId);
expect(await screen.findByRole('heading', { name: /Tools.*Import/ })).toBeInTheDocument(); // Header
expect(screen.getByRole('heading', { name: 'Previous Imports' })).toBeInTheDocument();
expect(screen.getAllByRole('link', { name: /DemoX 2025 T[0-5]/ })).toHaveLength(4);
});
it('should render the empty state', async () => {
render(mockGetCourseImports.emptyLibraryId);
expect(await screen.findByRole('heading', { name: /Tools.*Import/ })).toBeInTheDocument(); // Header
expect(screen.queryByRole('heading', { name: 'Previous Imports' })).not.toBeInTheDocument();
expect(screen.getByText('You have not imported any courses into this library.')).toBeInTheDocument();
});
});