test-errors.js 842 B

12345678910111213141516171819202122232425262728293031323334353637
  1. var server = require('./server')
  2. , events = require('events')
  3. , assert = require('assert')
  4. , request = require('../index')
  5. ;
  6. var local = 'http://localhost:8888/asdf'
  7. try {
  8. request({uri:local, body:{}})
  9. assert.fail("Should have throw")
  10. } catch(e) {
  11. assert.equal(e.message, 'Argument error, options.body.')
  12. }
  13. try {
  14. request({uri:local, multipart: 'foo'})
  15. assert.fail("Should have throw")
  16. } catch(e) {
  17. assert.equal(e.message, 'Argument error, options.multipart.')
  18. }
  19. try {
  20. request({uri:local, multipart: [{}]})
  21. assert.fail("Should have throw")
  22. } catch(e) {
  23. assert.equal(e.message, 'Body attribute missing in multipart.')
  24. }
  25. try {
  26. request(local, {multipart: [{}]})
  27. assert.fail("Should have throw")
  28. } catch(e) {
  29. assert.equal(e.message, 'Body attribute missing in multipart.')
  30. }
  31. console.log("All tests passed.")