@@ -25,24 +25,24 @@ describe('<UnitTranslationPlugin />', () => {
25
25
const mockInitialState = ( { enabled = true , availableLanguages = [ 'en' ] } ) => {
26
26
useState . mockReturnValue ( [ { enabled, availableLanguages } , jest . fn ( ) ] ) ;
27
27
} ;
28
+ when ( useModel )
29
+ . calledWith ( 'coursewareMeta' , props . courseId )
30
+ . mockReturnValue ( { language : 'en' } )
31
+ . calledWith ( 'courseHomeMeta' , props . courseId )
32
+ . mockReturnValue ( { enrollmentMode : 'verified' } ) ;
33
+
34
+ beforeEach ( ( ) => {
35
+ jest . clearAllMocks ( ) ;
36
+ } ) ;
37
+
28
38
it ( 'render empty when translation is not enabled' , ( ) => {
29
- when ( useModel )
30
- . calledWith ( 'coursewareMeta' , props . courseId )
31
- . mockReturnValueOnce ( { language : 'en' } )
32
- . calledWith ( 'courseHomeMeta' , props . courseId )
33
- . mockReturnValueOnce ( { verifiedMode : { accessExpirationDate : null } } ) ;
34
39
mockInitialState ( { enabled : false } ) ;
35
40
36
41
const wrapper = shallow ( < UnitTranslationPlugin { ...props } /> ) ;
37
42
38
43
expect ( wrapper . isEmptyRender ( ) ) . toBe ( true ) ;
39
44
} ) ;
40
45
it ( 'render empty when available languages is empty' , ( ) => {
41
- when ( useModel )
42
- . calledWith ( 'coursewareMeta' , props . courseId )
43
- . mockReturnValueOnce ( { language : 'fr' } )
44
- . calledWith ( 'courseHomeMeta' , props . courseId )
45
- . mockReturnValueOnce ( { verifiedMode : { accessExpirationDate : null } } ) ;
46
46
mockInitialState ( {
47
47
availableLanguages : [ ] ,
48
48
} ) ;
@@ -55,22 +55,18 @@ describe('<UnitTranslationPlugin />', () => {
55
55
it ( 'render empty when course language has not been set' , ( ) => {
56
56
when ( useModel )
57
57
. calledWith ( 'coursewareMeta' , props . courseId )
58
- . mockReturnValueOnce ( { language : undefined } )
59
- . calledWith ( 'courseHomeMeta' , props . courseId )
60
- . mockReturnValueOnce ( { verifiedMode : { accessExpirationDate : null } } ) ;
58
+ . mockReturnValueOnce ( { language : null } ) ;
61
59
mockInitialState ( { } ) ;
62
60
63
61
const wrapper = shallow ( < UnitTranslationPlugin { ...props } /> ) ;
64
62
65
63
expect ( wrapper . isEmptyRender ( ) ) . toBe ( true ) ;
66
64
} ) ;
67
65
68
- it ( 'render empty when verifiedMode has not been set ' , ( ) => {
66
+ it ( 'render empty when student is enroll as verified ' , ( ) => {
69
67
when ( useModel )
70
- . calledWith ( 'coursewareMeta' , props . courseId )
71
- . mockReturnValueOnce ( { language : 'en' } )
72
68
. calledWith ( 'courseHomeMeta' , props . courseId )
73
- . mockReturnValueOnce ( { verifiedMode : null } ) ;
69
+ . mockReturnValueOnce ( { enrollmentMode : 'audit' } ) ;
74
70
mockInitialState ( { } ) ;
75
71
76
72
const wrapper = shallow ( < UnitTranslationPlugin { ...props } /> ) ;
@@ -79,11 +75,6 @@ describe('<UnitTranslationPlugin />', () => {
79
75
} ) ;
80
76
81
77
it ( 'render TranslationSelection when translation is enabled and language is available' , ( ) => {
82
- when ( useModel )
83
- . calledWith ( 'coursewareMeta' , props . courseId )
84
- . mockReturnValueOnce ( { language : 'en' } )
85
- . calledWith ( 'courseHomeMeta' , props . courseId )
86
- . mockReturnValueOnce ( { verifiedMode : { accessExpirationDate : null } } ) ;
87
78
mockInitialState ( { } ) ;
88
79
89
80
const wrapper = shallow ( < UnitTranslationPlugin { ...props } /> ) ;
0 commit comments