Skip to content

Commit e06d410

Browse files
Robert MiddletonRobert Middleton
authored andcommitted
Added test to SeatingChartView Rendering.
1 parent 93d9b82 commit e06d410

File tree

2 files changed

+27
-1
lines changed

2 files changed

+27
-1
lines changed

src/Components/CourseHome/CourseHome.tsx

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ function CourseHome() {
9292
<FormControl style={{ minWidth: '150px', marginLeft: '21px', marginTop: '6px' }}>
9393
<InputLabel>View As</InputLabel>
9494
<Select
95+
inputProps={{ 'data-testid': 'courseHomeViewSelector' }}
96+
// data-testid="courseHomeViewSelector"
9597
value={viewType}
9698
onChange={handleChange}
9799
classes={{ root: classes.menuItem }}
@@ -105,7 +107,10 @@ function CourseHome() {
105107
</Select>
106108
</FormControl>
107109

108-
<div style={{ marginTop: '12px', borderTop: '1px', borderTopStyle: 'solid' }}>
110+
<div
111+
data-testid={viewType}
112+
style={{ marginTop: '12px', borderTop: '1px', borderTopStyle: 'solid' }}
113+
>
109114
{missionMasteryData ? (
110115
viewType === 'List' ? (
111116
<div className="base-table">
@@ -115,6 +120,7 @@ function CourseHome() {
115120
</div>
116121
) : (
117122
<SeatingChartView
123+
inputProps={{ 'data-testid': 'seatingChartView' }}
118124
classMissionMasterydata={missionMasteryData.classMissionMastery}
119125
/>
120126
)

src/tests/course-home.test.tsx

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
import React from 'react';
2+
import CourseHome from '../Components/CourseHome/CourseHome';
3+
import { render, fireEvent, waitFor, screen } from './test-utils';
4+
5+
test('my tets', async () => {
6+
// Arange
7+
render(<CourseHome />);
8+
9+
// Act
10+
await waitFor(() => screen.getByTestId('courseHomeViewSelector'));
11+
12+
fireEvent.change(screen.getByTestId('courseHomeViewSelector'), {
13+
target: { value: 'Chart' },
14+
});
15+
16+
await waitFor(() => screen.queryByTestId('Chart'));
17+
18+
// Assert
19+
expect(screen.queryByTestId('Chart')).toBeTruthy();
20+
});

0 commit comments

Comments
 (0)