@@ -83,25 +83,46 @@ const createRecommendation = (
8383} )
8484
8585describe ( 'pointRecommendCourses' , ( ) => {
86- it ( 'filters out exam courses unless replacement is positive ' , ( ) => {
87- const user = createUserCoordinates ( )
86+ it ( 'filters out exam courses when exam is a strict field and user coordinate is no ' , ( ) => {
87+ const user = createUserCoordinates ( { exam : 0 } )
8888
8989 const examCourse = createRecommendation ( 'exam-filtered' , {
9090 course : { name : { fi : 'Lopputentti' } } ,
91- coordinates : { replacement : 0 } ,
91+ coordinates : { exam : 1 } ,
9292 } )
93- const replacementExamCourse = createRecommendation ( 'exam-allowed' , {
94- course : { name : { fi : 'Korvaava tentti ' } } ,
95- coordinates : { replacement : 1 } ,
93+ const nonExamCourse = createRecommendation ( 'non- exam-allowed' , {
94+ course : { name : { fi : 'Regular course ' } } ,
95+ coordinates : { exam : 0 } ,
9696 } )
9797
9898 const result = pointRecommendedCourses (
99- [ examCourse , replacementExamCourse ] ,
99+ [ examCourse , nonExamCourse ] ,
100+ user ,
101+ [ 'exam' ]
102+ )
103+
104+ expect ( result . map ( ( course ) => course . course . id ) ) . toEqual ( [ 'non-exam-allowed' ] )
105+ } )
106+
107+ it ( 'keeps exam courses when exam is not a strict field' , ( ) => {
108+ const user = createUserCoordinates ( { exam : 0 } )
109+
110+ const examCourse = createRecommendation ( 'exam-course' , {
111+ course : { name : { fi : 'Lopputentti' } } ,
112+ coordinates : { exam : 1 } ,
113+ } )
114+ const nonExamCourse = createRecommendation ( 'non-exam-course' , {
115+ course : { name : { fi : 'Regular course' } } ,
116+ coordinates : { exam : 0 } ,
117+ } )
118+
119+ const result = pointRecommendedCourses (
120+ [ examCourse , nonExamCourse ] ,
100121 user ,
101122 [ ]
102123 )
103124
104- expect ( result . map ( ( course ) => course . course . id ) ) . toEqual ( [ 'exam-allowed' ] )
125+ expect ( result ) . toHaveLength ( 2 )
105126 } )
106127
107128 it ( 'filters on strict fields and keeps non-strict mismatches' , ( ) => {
0 commit comments