8
8
screen ,
9
9
waitFor ,
10
10
} from '../../setupTest' ;
11
- import { CoursewareSearchResultsFilter , filteredResultsBySelection } from './CoursewareResultsFilter' ;
11
+ import { CoursewareSearchResultsFilter } from './CoursewareResultsFilter' ;
12
12
import { useCoursewareSearchParams } from './hooks' ;
13
13
import initializeStore from '../../store' ;
14
14
import { useModel } from '../../generic/model-store' ;
@@ -19,27 +19,6 @@ jest.mock('../../generic/model-store', () => ({
19
19
useModel : jest . fn ( ) ,
20
20
} ) ) ;
21
21
22
- const mockResults = [
23
- {
24
- id : 'video-1' , type : 'video' , title : 'video_title' , score : 3 , contentHits : 1 , url : '/video-1' , location : [ 'path1' , 'path2' ] ,
25
- } ,
26
- {
27
- id : 'video-2' , type : 'video' , title : 'video_title2' , score : 2 , contentHits : 1 , url : '/video-2' , location : [ 'path1' , 'path2' ] ,
28
- } ,
29
- {
30
- id : 'document-1' , type : 'document' , title : 'document_title' , score : 3 , contentHits : 1 , url : '/document-1' , location : [ 'path1' , 'path2' ] ,
31
- } ,
32
- {
33
- id : 'text-1' , type : 'text' , title : 'text_title1' , score : 3 , contentHits : 1 , url : '/text-1' , location : [ 'path1' , 'path2' ] ,
34
- } ,
35
- {
36
- id : 'text-2' , type : 'text' , title : 'text_title2' , score : 2 , contentHits : 1 , url : '/text-2' , location : [ 'path1' , 'path2' ] ,
37
- } ,
38
- {
39
- id : 'text-3' , type : 'text' , title : 'text_title3' , score : 1 , contentHits : 1 , url : '/text-3' , location : [ 'path1' , 'path2' ] ,
40
- } ,
41
- ] ;
42
-
43
22
const decodedCourseId = 'course-v1:edX+DemoX+Demo_Course' ;
44
23
const decodedSequenceId = 'block-v1:edX+DemoX+Demo_Course+type@sequential+block@edx_introduction' ;
45
24
const decodedUnitId = 'block-v1:edX+DemoX+Demo_Course+type@vertical+block@vertical_0270f6de40fc' ;
@@ -73,38 +52,6 @@ function renderComponent(props = {}) {
73
52
describe ( 'CoursewareSearchResultsFilter' , ( ) => {
74
53
beforeAll ( initializeMockApp ) ;
75
54
76
- describe ( 'filteredResultsBySelection' , ( ) => {
77
- it ( 'returns a no values array when no results are provided' , ( ) => {
78
- const results = filteredResultsBySelection ( { } ) ;
79
-
80
- expect ( results . length ) . toEqual ( 0 ) ;
81
- } ) ;
82
-
83
- it ( 'returns all values when no key value is provided' , ( ) => {
84
- const results = filteredResultsBySelection ( { results : mockResults } ) ;
85
-
86
- expect ( results . length ) . toEqual ( mockResults . length ) ;
87
- } ) ;
88
-
89
- it ( 'returns only "video"-typed elements when the key value "video" is given' , ( ) => {
90
- const results = filteredResultsBySelection ( { key : 'video' , results : mockResults } ) ;
91
-
92
- expect ( results . length ) . toEqual ( 2 ) ;
93
- } ) ;
94
-
95
- it ( 'returns only "course_outline"-typed elements when the key value "document" is given' , ( ) => {
96
- const results = filteredResultsBySelection ( { key : 'document' , results : mockResults } ) ;
97
-
98
- expect ( results . length ) . toEqual ( 1 ) ;
99
- } ) ;
100
-
101
- it ( 'returns only "text"-typed elements when the key value "text" is given' , ( ) => {
102
- const results = filteredResultsBySelection ( { key : 'text' , results : mockResults } ) ;
103
-
104
- expect ( results . length ) . toEqual ( 3 ) ;
105
- } ) ;
106
- } ) ;
107
-
108
55
describe ( '</CoursewareSearchResultsFilter />' , ( ) => {
109
56
beforeEach ( ( ) => {
110
57
jest . clearAllMocks ( ) ;
@@ -117,8 +64,11 @@ describe('CoursewareSearchResultsFilter', () => {
117
64
await renderComponent ( ) ;
118
65
119
66
await waitFor ( ( ) => {
120
- expect ( screen . queryByTestId ( 'courseware-search-results-tabs' ) ) . toBeInTheDocument ( ) ;
121
- expect ( screen . queryByText ( / A l l c o n t e n t / ) ) . toBeInTheDocument ( ) ;
67
+ expect ( screen . queryByTestId ( 'courseware-search-results-tabs-all' ) ) . toBeInTheDocument ( ) ;
68
+ expect ( screen . queryByTestId ( 'courseware-search-results-tabs-text' ) ) . toBeInTheDocument ( ) ;
69
+ expect ( screen . queryByTestId ( 'courseware-search-results-tabs-video' ) ) . toBeInTheDocument ( ) ;
70
+ expect ( screen . queryByTestId ( 'courseware-search-results-tabs-sequence' ) ) . toBeInTheDocument ( ) ;
71
+ expect ( screen . queryByTestId ( 'courseware-search-results-tabs-other' ) ) . toBeInTheDocument ( ) ;
122
72
} ) ;
123
73
} ) ;
124
74
} ) ;
0 commit comments