@@ -69,34 +69,28 @@ describe('maskSigUrl', () => {
69
69
jest . clearAllMocks ( )
70
70
} )
71
71
72
- it ( 'returns the original URL if no sig parameter is present' , ( ) => {
72
+ it ( 'does nothing if no sig parameter is present' , ( ) => {
73
73
const url = 'https://example.com'
74
- const maskedUrl = maskSigUrl ( url )
75
- expect ( maskedUrl ) . toBe ( url )
74
+ maskSigUrl ( url )
76
75
expect ( setSecret ) . not . toHaveBeenCalled ( )
77
76
} )
78
77
79
78
it ( 'masks the sig parameter in the middle of the URL and sets it as a secret' , ( ) => {
80
79
const url = 'https://example.com/?param1=value1&sig=12345¶m2=value2'
81
- const maskedUrl = maskSigUrl ( url )
82
- expect ( maskedUrl ) . toBe (
83
- 'https://example.com/?param1=value1&sig=***¶m2=value2'
84
- )
80
+ maskSigUrl ( url )
85
81
expect ( setSecret ) . toHaveBeenCalledWith ( '12345' )
86
82
expect ( setSecret ) . toHaveBeenCalledWith ( encodeURIComponent ( '12345' ) )
87
83
} )
88
84
89
- it ( 'returns the original URL if it is empty' , ( ) => {
85
+ it ( 'does nothing if the URL is empty' , ( ) => {
90
86
const url = ''
91
- const maskedUrl = maskSigUrl ( url )
92
- expect ( maskedUrl ) . toBe ( '' )
87
+ maskSigUrl ( url )
93
88
expect ( setSecret ) . not . toHaveBeenCalled ( )
94
89
} )
95
90
96
91
it ( 'handles URLs with fragments' , ( ) => {
97
92
const url = 'https://example.com?sig=12345#fragment'
98
- const maskedUrl = maskSigUrl ( url )
99
- expect ( maskedUrl ) . toBe ( 'https://example.com/?sig=***#fragment' )
93
+ maskSigUrl ( url )
100
94
expect ( setSecret ) . toHaveBeenCalledWith ( '12345' )
101
95
expect ( setSecret ) . toHaveBeenCalledWith ( encodeURIComponent ( '12345' ) )
102
96
} )
0 commit comments