-
-
-
-
-
-`;
diff --git a/src/course-home/courseware-search/CoursewareSearchEmpty.test.jsx b/src/course-home/courseware-search/CoursewareSearchEmpty.test.jsx
index 7ef5909a15..0a17a4f37f 100644
--- a/src/course-home/courseware-search/CoursewareSearchEmpty.test.jsx
+++ b/src/course-home/courseware-search/CoursewareSearchEmpty.test.jsx
@@ -5,6 +5,7 @@ import {
screen,
} from '../../setupTest';
import CoursewareSearchEmpty from './CoursewareSearchEmpty';
+import messages from './messages';
function renderComponent() {
const { container } = render();
@@ -16,9 +17,12 @@ describe('CoursewareSearchEmpty', () => {
initializeMockApp();
});
- it('should match the snapshot', () => {
+ it('render empty results text and corresponding classes', () => {
renderComponent();
-
- expect(screen.getByTestId('no-results')).toMatchSnapshot();
+ const emptyText = screen.getByText(messages.searchResultsNone.defaultMessage);
+ expect(emptyText).toBeInTheDocument();
+ expect(emptyText).toHaveClass('courseware-search-results__empty');
+ expect(emptyText).toHaveAttribute('data-testid', 'no-results');
+ expect(emptyText.parentElement).toHaveClass('courseware-search-results');
});
});
diff --git a/src/course-home/courseware-search/CoursewareSearchResults.test.jsx b/src/course-home/courseware-search/CoursewareSearchResults.test.jsx
index eae95083a4..664a94e825 100644
--- a/src/course-home/courseware-search/CoursewareSearchResults.test.jsx
+++ b/src/course-home/courseware-search/CoursewareSearchResults.test.jsx
@@ -7,6 +7,7 @@ import {
import CoursewareSearchResults from './CoursewareSearchResults';
import messages from './messages';
import searchResultsFactory from './test-data/search-results-factory';
+import * as mock from './test-data/mocked-response.json';
jest.mock('react-redux');
@@ -34,8 +35,15 @@ describe('CoursewareSearchResults', () => {
renderComponent({ results });
});
- it('should match the snapshot', () => {
- expect(screen.getByTestId('search-results')).toMatchSnapshot();
+ it('should render complete list', () => {
+ const courses = screen.getAllByRole('link');
+ expect(courses.length).toBe(mock.results.length);
+ });
+
+ it('should render correct title for first course', () => {
+ const courses = screen.getAllByRole('link');
+ const firstCourseTitle = courses[0].querySelector('.courseware-search-results__title span');
+ expect(firstCourseTitle.innerHTML).toEqual(mock.results[0].data.content.display_name);
});
});
});
diff --git a/src/course-home/courseware-search/__snapshots__/CoursewareSearchEmpty.test.jsx.snap b/src/course-home/courseware-search/__snapshots__/CoursewareSearchEmpty.test.jsx.snap
deleted file mode 100644
index e87c856ea0..0000000000
--- a/src/course-home/courseware-search/__snapshots__/CoursewareSearchEmpty.test.jsx.snap
+++ /dev/null
@@ -1,10 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`CoursewareSearchEmpty should match the snapshot 1`] = `
-
- No results found.
-
-`;
diff --git a/src/course-home/courseware-search/__snapshots__/CoursewareSearchResults.test.jsx.snap b/src/course-home/courseware-search/__snapshots__/CoursewareSearchResults.test.jsx.snap
deleted file mode 100644
index 12178a62ed..0000000000
--- a/src/course-home/courseware-search/__snapshots__/CoursewareSearchResults.test.jsx.snap
+++ /dev/null
@@ -1,1238 +0,0 @@
-// Jest Snapshot v1, https://goo.gl/fbAQLP
-
-exports[`CoursewareSearchResults when list of results is provided should match the snapshot 1`] = `
-