Skip to content

Commit

Permalink
test: add unit test
Browse files Browse the repository at this point in the history
  • Loading branch information
cdeery committed Aug 10, 2023
1 parent 58e1901 commit 6123e58
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,9 @@ const RecommendationStack = ({ selectedRecommendations, productTypeNames }) => {
const numberResults = productTypeRecommendations?.length;
const isExpanded = expandedList.includes(productTypeName);

if (numberResults === 0) {
return null;
}
return (
<Stack gap={2.5} key={productTypeName}>
<ProductTypeBanner
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,23 @@ describe('view-results', () => {
expect(screen.getByText(messages.productTypeProgramDescription.defaultMessage)).toBeTruthy();
expect(screen.getByText(messages.productTypeCourseDescription.defaultMessage)).toBeTruthy();
});

it('hides a LOB if there are no results', async () => {
getProductRecommendations.mockImplementation((productIndex, productType) => {
if (productType === 'boot_camp') {
return mockData.productRecommendations;
}
return [];
});

// This one should not be true - no recommendations provided
expect(screen.getByText(messages.productTypeBootCampDescription.defaultMessage)).toBeFalsy();
// These should all work.
expect(screen.getByText(messages.productTypeDegreeDescription.defaultMessage)).toBeTruthy();
expect(screen.getByText(messages.productTypeExecutiveEducationDescription.defaultMessage)).toBeTruthy();
expect(screen.getByText(messages.productTypeProgramDescription.defaultMessage)).toBeTruthy();
expect(screen.getByText(messages.productTypeCourseDescription.defaultMessage)).toBeTruthy();
});
});

describe('show all button', () => {
Expand Down

0 comments on commit 6123e58

Please sign in to comment.