Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 42 additions & 0 deletions src/studio-home/tabs-section/courses-tab/index.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -131,4 +131,46 @@ describe('<CoursesTab />', () => {
const state = store.getState();
expect(state.studioHome.studioHomeCoursesRequestParams).toStrictEqual(studioHomeCoursesRequestParamsDefault);
});

it('should render displayNumber in the card subtitle when it is provided', () => {
const courseWithDisplayNumber = {
...studioHomeMock.courses[0],
number: '123',
displayNumber: 'DISP-999',
};
renderComponent({ coursesDataItems: [courseWithDisplayNumber] });
expect(screen.getByText(/DISP-999/)).toBeInTheDocument();
expect(screen.queryByText(/\/ 123 \//)).not.toBeInTheDocument();
});

it('should fall back to number in the card subtitle when displayNumber is empty', () => {
const courseWithEmptyDisplayNumber = {
...studioHomeMock.courses[0],
number: '123',
displayNumber: '',
};
renderComponent({ coursesDataItems: [courseWithEmptyDisplayNumber] });
expect(screen.getByText(/\/ 123 \//)).toBeInTheDocument();
});

it('should render displayOrg in the card subtitle when it is provided', () => {
const courseWithDisplayOrg = {
...studioHomeMock.courses[0],
org: 'HarvardX',
displayOrg: 'Harvard University',
};
renderComponent({ coursesDataItems: [courseWithDisplayOrg] });
expect(screen.getByText(/Harvard University \//)).toBeInTheDocument();
expect(screen.queryByText(/HarvardX \//)).not.toBeInTheDocument();
});

it('should fall back to org in the card subtitle when displayOrg is empty', () => {
const courseWithEmptyDisplayOrg = {
...studioHomeMock.courses[0],
org: 'HarvardX',
displayOrg: '',
};
renderComponent({ coursesDataItems: [courseWithEmptyDisplayOrg] });
expect(screen.getByText(/HarvardX \//)).toBeInTheDocument();
});
});
8 changes: 6 additions & 2 deletions src/studio-home/tabs-section/courses-tab/index.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,9 @@ interface Props {
displayName: string;
lmsLink: string | null;
number: string;
displayNumber?: string | null;

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

in the ULMO version I had to add this change, because this component is a little bit different comparing to master and verawood

org: string;
displayOrg?: string | null;
rerunLink: string | null;
run: string;
url: string;
Expand Down Expand Up @@ -138,8 +140,10 @@ const CoursesTab: React.FC<Props> = ({
displayName,
lmsLink,
org,
displayOrg,
rerunLink,
number,
displayNumber,
run,
url,
}) => (
Expand All @@ -149,8 +153,8 @@ const CoursesTab: React.FC<Props> = ({
displayName={displayName}
lmsLink={lmsLink}
rerunLink={rerunLink}
org={org}
number={number}
org={displayOrg || org}
number={displayNumber || number}
run={run}
url={url}
/>
Expand Down
Loading