@@ -11,26 +11,52 @@ describe('getAvatarUrl', () => {
11
11
} )
12
12
13
13
it ( 'should return correct relative URL for user avatar' , ( ) => {
14
- expect ( getAvatarUrl ( 'john' , 44 ) ) . toBe ( '//index.php/avatar/john/44' )
15
- expect ( getAvatarUrl ( 'alice' , '64' , false ) ) . toBe ( '//index.php/avatar/alice/64' )
14
+ expect ( getAvatarUrl ( 'alice' ) ) . toBe ( '//index.php/avatar/alice/64' )
15
+ expect ( getAvatarUrl ( 'john' , { size : 44 } ) ) . toBe ( '//index.php/avatar/john/64' )
16
+ } )
17
+
18
+ it ( 'should return correct relative URL with fixed sizes' , ( ) => {
19
+ expect ( getAvatarUrl ( 'alice' , { size : 0 } ) ) . toBe ( '//index.php/avatar/alice/64' )
20
+ expect ( getAvatarUrl ( 'alice' , { size : - 1 } ) ) . toBe ( '//index.php/avatar/alice/64' )
21
+ expect ( getAvatarUrl ( 'john' , { size : 64 } ) ) . toBe ( '//index.php/avatar/john/64' )
22
+ expect ( getAvatarUrl ( 'john' , { size : 65 } ) ) . toBe ( '//index.php/avatar/john/512' )
23
+ } )
24
+
25
+ it ( 'should return correct relative URL for user avatar in dark mode' , ( ) => {
26
+ document . body . style . setProperty ( '--background-invert-if-dark' , 'invert(100%)' )
27
+
28
+ expect ( getAvatarUrl ( 'alice' ) ) . toBe ( '//index.php/avatar/alice/64/dark' )
29
+ expect ( getAvatarUrl ( 'john' , { size : 44 } ) ) . toBe ( '//index.php/avatar/john/64/dark' )
30
+ } )
31
+
32
+ it ( 'should return correct relative URL for user avatar in dark mode if enforced' , ( ) => {
33
+ expect ( getAvatarUrl ( 'alice' , { isDarkTheme : true } ) ) . toBe ( '//index.php/avatar/alice/64/dark' )
34
+ expect ( getAvatarUrl ( 'john' , { isDarkTheme : true , size : 128 } ) ) . toBe ( '//index.php/avatar/john/512/dark' )
35
+ } )
36
+
37
+ it ( 'should return correct relative URL for user avatar in bright mode if enforced but body is darkmode' , ( ) => {
38
+ document . body . style . setProperty ( '--background-invert-if-dark' , 'invert(100%)' )
39
+
40
+ expect ( getAvatarUrl ( 'alice' , { isDarkTheme : false } ) ) . toBe ( '//index.php/avatar/alice/64' )
41
+ expect ( getAvatarUrl ( 'john' , { isDarkTheme : false , size : 128 } ) ) . toBe ( '//index.php/avatar/john/512' )
16
42
} )
17
43
18
44
it ( 'should return correct relative URL for user avatar in dark mode' , ( ) => {
19
45
document . body . style . setProperty ( '--background-invert-if-dark' , 'invert(100%)' )
20
46
21
- expect ( getAvatarUrl ( 'john' , 44 ) ) . toBe ( '//index.php/avatar/john/44 /dark' )
22
- expect ( getAvatarUrl ( 'alice ' , '64' , false ) ) . toBe ( '//index.php/avatar/alice /64/dark' )
47
+ expect ( getAvatarUrl ( 'alice' ) ) . toBe ( '//index.php/avatar/alice/64 /dark' )
48
+ expect ( getAvatarUrl ( 'john ' , { size : 44 } ) ) . toBe ( '//index.php/avatar/john /64/dark' )
23
49
} )
24
50
25
51
it ( 'should return correct relative URL for guest avatar' , ( ) => {
26
- expect ( getAvatarUrl ( 'john ' , 44 , true ) ) . toBe ( '//index.php/avatar/guest/john/44 ' )
27
- expect ( getAvatarUrl ( 'alice ' , '64' , true ) ) . toBe ( '//index.php/avatar/guest/alice /64' )
52
+ expect ( getAvatarUrl ( 'alice ' , { isGuest : true } ) ) . toBe ( '//index.php/avatar/guest/alice/64 ' )
53
+ expect ( getAvatarUrl ( 'john ' , { size : 44 , isGuest : true } ) ) . toBe ( '//index.php/avatar/guest/john /64' )
28
54
} )
29
55
30
56
it ( 'should return correct relative URL for guest avatar in dark mode' , ( ) => {
31
57
document . body . style . setProperty ( '--background-invert-if-dark' , 'invert(100%)' )
32
58
33
- expect ( getAvatarUrl ( 'john ' , 44 , true ) ) . toBe ( '//index.php/avatar/guest/john/44 /dark' )
34
- expect ( getAvatarUrl ( 'alice ' , '64' , true ) ) . toBe ( '//index.php/avatar/guest/alice /64/dark' )
59
+ expect ( getAvatarUrl ( 'alice ' , { isGuest : true } ) ) . toBe ( '//index.php/avatar/guest/alice/64 /dark' )
60
+ expect ( getAvatarUrl ( 'john ' , { size : 44 , isGuest : true } ) ) . toBe ( '//index.php/avatar/guest/john /64/dark' )
35
61
} )
36
62
} )
0 commit comments