-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
86 additions
and
5 deletions.
There are no files selected for viewing
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
79 changes: 79 additions & 0 deletions
79
...lient/app/bundles/Teacher/components/assignment_flow/manage_units/__tests__/unit.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
import React from 'react'; | ||
import { render, screen } from '@testing-library/react'; | ||
import '@testing-library/jest-dom'; | ||
import Unit from '../unit'; | ||
|
||
const mockData = { | ||
classroomActivities: new Map([ | ||
[ | ||
'1', | ||
{ | ||
name: 'Activity 1', | ||
completed: false, | ||
started: false, | ||
studentCount: 10, | ||
ownedByCurrentUser: true, | ||
ownerName: 'Teacher A', | ||
activityId: 'a1', | ||
classroom_unit_id: 'cu1', | ||
}, | ||
], | ||
[ | ||
'2', | ||
{ | ||
name: 'Activity 2', | ||
completed: true, | ||
started: true, | ||
studentCount: 0, | ||
ownedByCurrentUser: false, | ||
ownerName: 'Teacher B', | ||
activityId: 'a2', | ||
classroom_unit_id: 'cu2', | ||
}, | ||
], | ||
]), | ||
classrooms: ['Class 1', 'Class 2'], | ||
num_students_assigned: 20, | ||
unitName: 'Sample Unit', | ||
unitId: 'unit1', | ||
}; | ||
|
||
describe('Unit Component', () => { | ||
it('renders the unit name and assigned information', () => { | ||
render(<Unit data={mockData} />); | ||
|
||
expect(screen.getByText('Sample Unit')).toBeInTheDocument(); | ||
expect(screen.getByText('Assigned to')).toBeInTheDocument(); | ||
expect(screen.getByText('20 Students')).toBeInTheDocument(); | ||
expect(screen.getByText('2 classes (Class 1, Class 2)')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders classroom activities as rows in the DataTable', () => { | ||
render(<Unit data={mockData} />); | ||
|
||
expect(screen.getByText('Activity 1')).toBeInTheDocument(); | ||
expect(screen.getByText('Activity 2')).toBeInTheDocument(); | ||
}); | ||
|
||
it('renders launch lesson options based on activity state', () => { | ||
render(<Unit data={mockData} />); | ||
|
||
const launchButtons = screen.getAllByText('Launch Lesson'); | ||
expect(launchButtons.length).toBeGreaterThan(0); | ||
|
||
const viewReportButtons = screen.getAllByText('View Report'); | ||
expect(viewReportButtons.length).toBeGreaterThan(0); | ||
}); | ||
|
||
it('renders the customize and download links', () => { | ||
render(<Unit data={mockData} />); | ||
|
||
const customizeIcons = screen.getAllByAltText('extra small pencil icon'); | ||
expect(customizeIcons[0]).toBeInTheDocument(); | ||
expect(customizeIcons[1]).toBeInTheDocument(); | ||
|
||
const downloadIcons = screen.getAllByAltText('extra small arrow down icon'); | ||
expect(downloadIcons[0]).toBeInTheDocument(); | ||
expect(downloadIcons[1]).toBeInTheDocument(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters