mirror of
https://git.mirrors.martin98.com/https://github.com/actions/toolkit
synced 2025-08-22 02:19:07 +08:00
fix tests
This commit is contained in:
parent
6876e2a664
commit
d13e6311f1
@ -69,34 +69,28 @@ describe('maskSigUrl', () => {
|
|||||||
jest.clearAllMocks()
|
jest.clearAllMocks()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the original URL if no sig parameter is present', () => {
|
it('does nothing if no sig parameter is present', () => {
|
||||||
const url = 'https://example.com'
|
const url = 'https://example.com'
|
||||||
const maskedUrl = maskSigUrl(url)
|
maskSigUrl(url)
|
||||||
expect(maskedUrl).toBe(url)
|
|
||||||
expect(setSecret).not.toHaveBeenCalled()
|
expect(setSecret).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('masks the sig parameter in the middle of the URL and sets it as a secret', () => {
|
it('masks the sig parameter in the middle of the URL and sets it as a secret', () => {
|
||||||
const url = 'https://example.com/?param1=value1&sig=12345¶m2=value2'
|
const url = 'https://example.com/?param1=value1&sig=12345¶m2=value2'
|
||||||
const maskedUrl = maskSigUrl(url)
|
maskSigUrl(url)
|
||||||
expect(maskedUrl).toBe(
|
|
||||||
'https://example.com/?param1=value1&sig=***¶m2=value2'
|
|
||||||
)
|
|
||||||
expect(setSecret).toHaveBeenCalledWith('12345')
|
expect(setSecret).toHaveBeenCalledWith('12345')
|
||||||
expect(setSecret).toHaveBeenCalledWith(encodeURIComponent('12345'))
|
expect(setSecret).toHaveBeenCalledWith(encodeURIComponent('12345'))
|
||||||
})
|
})
|
||||||
|
|
||||||
it('returns the original URL if it is empty', () => {
|
it('does nothing if the URL is empty', () => {
|
||||||
const url = ''
|
const url = ''
|
||||||
const maskedUrl = maskSigUrl(url)
|
maskSigUrl(url)
|
||||||
expect(maskedUrl).toBe('')
|
|
||||||
expect(setSecret).not.toHaveBeenCalled()
|
expect(setSecret).not.toHaveBeenCalled()
|
||||||
})
|
})
|
||||||
|
|
||||||
it('handles URLs with fragments', () => {
|
it('handles URLs with fragments', () => {
|
||||||
const url = 'https://example.com?sig=12345#fragment'
|
const url = 'https://example.com?sig=12345#fragment'
|
||||||
const maskedUrl = maskSigUrl(url)
|
maskSigUrl(url)
|
||||||
expect(maskedUrl).toBe('https://example.com/?sig=***#fragment')
|
|
||||||
expect(setSecret).toHaveBeenCalledWith('12345')
|
expect(setSecret).toHaveBeenCalledWith('12345')
|
||||||
expect(setSecret).toHaveBeenCalledWith(encodeURIComponent('12345'))
|
expect(setSecret).toHaveBeenCalledWith(encodeURIComponent('12345'))
|
||||||
})
|
})
|
||||||
|
Loading…
x
Reference in New Issue
Block a user