Skip to content

Commit

Permalink
test: fix missing it.runIf(Curl.isVersionGreaterOrEqualThan(7, 64, 0)…
Browse files Browse the repository at this point in the history
…) for test
  • Loading branch information
JCMais committed Dec 25, 2024
1 parent 1b76860 commit 9e64a80
Showing 1 changed file with 21 additions and 18 deletions.
39 changes: 21 additions & 18 deletions test/curl/easy.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -109,24 +109,27 @@ describe('easy', () => {
},
)

it('TRAILERFUNCTION - should throw error if has invalid return type', () => {
curl.setOpt('UPLOAD', true)
curl.setOpt('HTTPHEADER', ['x-random-header: random-value'])
// @ts-ignore
curl.setOpt('TRAILERFUNCTION', () => {
return {}
})
let finished = false
curl.setOpt(Curl.option.READFUNCTION, (buffer, _size, _nmemb) => {
if (finished) return 0
it.runIf(Curl.isVersionGreaterOrEqualThan(7, 64, 0))(
'TRAILERFUNCTION - should throw error if has invalid return type',
() => {
curl.setOpt('UPLOAD', true)
curl.setOpt('HTTPHEADER', ['x-random-header: random-value'])
// @ts-ignore
curl.setOpt('TRAILERFUNCTION', () => {
return {}
})
let finished = false
curl.setOpt(Curl.option.READFUNCTION, (buffer, _size, _nmemb) => {
if (finished) return 0

const data = 'HELLO'
finished = true
return buffer.write(data)
})
expect(() => curl.perform()).toThrow(
'Return value from the Trailer callback must be an array of strings or false.',
)
})
const data = 'HELLO'
finished = true
return buffer.write(data)
})
expect(() => curl.perform()).toThrow(
'Return value from the Trailer callback must be an array of strings or false.',
)
},
)
})
})

0 comments on commit 9e64a80

Please sign in to comment.