message: tests: test more callbacks on easy handle tests
diff: @@ -8,7 +8,7 @@ import 'should'
  import { Curl, CurlCode, Easy } from '../../lib'
  -const url = 'http://www.google.com/'
  +const url = 'http://example.com/'
  // This is the only test that does not uses a express server
  // It makes a request to a live server, which can cause issues if there are network problems
  @@ -31,7 +31,65 @@ describe('easy', () => {
  })
  describe('callbacks', () => {
  - it('should rethrow error thrown on callback', () => {
  + it('WRITEFUNCTION - should rethrow error', () => {
  + curl.setOpt('WRITEFUNCTION', () => {
  + throw new Error('Error thrown on callback')
  + })
  + const perform = () => curl.perform()
  + perform.should.throw('Error thrown on callback')
  + })
  + it('WRITEFUNCTION - should throw error if has invalid return type', () => {
  + // @ts-ignore
  + curl.setOpt('WRITEFUNCTION', () => {
  + return {}
  + })
  + const perform = () => curl.perform()
  + perform.should.throw(
  + 'Return value from the WRITE callback must be an integer.',
  + )
  + })
  +
  + it('HEADERFUNCTION - should rethrow error', () => {
  + curl.setOpt('HEADERFUNCTION', () => {
  + throw new Error('Error thrown on callback')
  + })
  + const perform = () => curl.perform()
  + perform.should.throw('Error thrown on callback')
  + })
  + it('HEADERFUNCTION - should throw error if has invalid return type', () => {
  + // @ts-ignore
  + curl.setOpt('HEADERFUNCTION', () => {
  + return {}
  + })
  + const perform = () => curl.perform()
  + perform.should.throw(
  + 'Return value from the HEADER callback must be an integer.',
  + )
  + })
  +
  + it('READFUNCTION - should rethrow error', () => {
  + curl.setOpt('UPLOAD', true)
  + // @ts-ignore
  + curl.setOpt('READFUNCTION', () => {
  + throw new Error('Error thrown on callback')
  + })
  + const perform = () => curl.perform()
  + perform.should.throw('Error thrown on callback')
  + })
  + it('READFUNCTION - should throw error if has invalid return type', () => {
  + curl.setOpt('UPLOAD', true)
  + // @ts-ignore
  + curl.setOpt('READFUNCTION', () => {
  + return {}
  + })
  + const perform = () => curl.perform()
  + perform.should.throw(
  + 'Return value from the READ callback must be an integer.',
  + )
  + })
  +
  + if (Curl.isVersionGreaterOrEqualThan(7, 64, 0)) {
  + it('TRAILERFUNCTION - should rethrow error', () => {
  curl.setOpt('UPLOAD', true)
  curl.setOpt('HTTPHEADER', ['x-random-header: random-value'])
  // @ts-ignore
  @@ -46,8 +104,7 @@ describe('easy', () => {
  const perform = () => curl.perform()
  perform.should.throw('Error thrown on callback')
  })
  -
  - it('should throw error if callback has invalid return type', () => {
  + it('TRAILERFUNCTION - should throw error if has invalid return type', () => {
  curl.setOpt('UPLOAD', true)
  curl.setOpt('HTTPHEADER', ['x-random-header: random-value'])
  // @ts-ignore
  @@ -64,5 +121,6 @@ describe('easy', () => {
  'Return value from the Trailer callback must be an array of strings or false.',
  )
  })
  + }
  })
  })
  