Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Added icon to honors sections
Browse files Browse the repository at this point in the history
  • Loading branch information
firejake308 committed May 8, 2020
1 parent ed95011 commit c80ab5d
Show file tree
Hide file tree
Showing 3 changed files with 61 additions and 1 deletion.
Expand Up @@ -34,6 +34,8 @@
/* position is sticky by default, which prevents the first instructor name from scrolling
with the rest of the SectionSelect */
position: initial;
display: flex;
align-items: center;
}

.gray-text {
Expand Down
Expand Up @@ -2,6 +2,7 @@ import * as React from 'react';
import {
List, ListItemText, ListItem, Checkbox, ListItemIcon, Typography, ListSubheader,
} from '@material-ui/core';
import HonorsIcon from '@material-ui/icons/School';
import { useSelector, useDispatch } from 'react-redux';
import Meeting, { MeetingType } from '../../../../../../types/Meeting';
import { formatTime } from '../../../../../../timeUtil';
Expand Down Expand Up @@ -69,6 +70,7 @@ const SectionSelect: React.FC<SectionSelectProps> = ({ id }): JSX.Element => {
? (
<ListSubheader disableGutters className={styles.listSubheaderDense}>
{section.instructor.name}
{section.honors ? <HonorsIcon titleAccess="honors" /> : null}
</ListSubheader>
)
: null;
Expand Down
58 changes: 57 additions & 1 deletion autoscheduler/frontend/src/tests/ui/CourseSelectCard.test.tsx
Expand Up @@ -133,6 +133,63 @@ describe('Course Select Card UI', () => {
});
});

describe('handles honors icon', () => {
test('by showing it for honors sections', async () => {
// arrange
fetchMock.mockResponseOnce(JSON.stringify({ // api/course/search
results: ['MATH 151'],
}));
fetchMock.mockImplementationOnce(testFetch); // api/sections

const store = createStore(autoSchedulerReducer, applyMiddleware(thunk));
store.dispatch(setTerm('201931'));
const {
getByText, getByLabelText, findByText, findByTitle,
} = render(
<Provider store={store}><CourseSelectCard id={0} /></Provider>,
);

// act
fireEvent.change(getByLabelText('Course'), { target: { value: 'M' } });
fireEvent.click(await findByText('MATH 151'));

// switch to sections view
fireEvent.click(getByText('Section'));
const honorsIcon = await findByTitle('honors');

// assert
expect(honorsIcon).toBeInTheDocument();
});

test('by hiding it for regular sections', async () => {
// arrange
fetchMock.mockResponseOnce(JSON.stringify({ // api/course/search
results: ['CSCE 121'],
}));
fetchMock.mockImplementationOnce(testFetch); // api/sections

const store = createStore(autoSchedulerReducer, applyMiddleware(thunk));
store.dispatch(setTerm('201931'));
const {
getByText, getByLabelText, findByText, queryByTitle,
} = render(
<Provider store={store}><CourseSelectCard id={0} /></Provider>,
);

// act
fireEvent.change(getByLabelText('Course'), { target: { value: 'C' } });
fireEvent.click(await findByText('CSCE 121'));

// switch to sections view
fireEvent.click(getByText('Section'));
await findByText((cont, el) => ignoreInvisible(cont, el, '501'));
const honorsIcon = queryByTitle('honors');

// assert
expect(honorsIcon).not.toBeInTheDocument();
});
});

describe('does not fetch inappropriately', () => {
describe('when we search and go to the Sections tab', () => {
test('and collapse then expand the card', async () => {
Expand Down Expand Up @@ -335,7 +392,6 @@ describe('Course Select Card UI', () => {
});
});


describe('hides the placeholder text', () => {
test('when the customization filter is Basic and there are honors sections', async () => {
// arrange
Expand Down

0 comments on commit c80ab5d

Please sign in to comment.