throws.test.coffee 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. process.env['NODE_ENV'] = 'development'
  2. fs = require 'fs'
  3. path = require 'path'
  4. gulp = require 'gulp'
  5. tap = require '../'
  6. tapTest = require 'tap'
  7. # helper function to get a path relative to the root
  8. getPath = (rel) -> path.resolve __dirname, '..', rel
  9. identity = (x) -> x
  10. tapTest.test "throw errors", (test) ->
  11. test.plan 2
  12. gulp.src getPath 'tests/fixtures/' + 'js.js'
  13. .pipe tap (file, t) ->
  14. test.throws t.through.bind(null, gulp.dest, "wrong"), new TypeError("Args must be an array to `apply` to the filter")
  15. gulp.src getPath 'tests/fixtures/' + 'js.js'
  16. .pipe tap (file, t) ->
  17. test.throws t.through.bind(null, identity, ["right"]), {}, "should throw if supplied function doesn't return a stream'"
  18. ### Giving up due to lack of knowledge about vinyl-fs streams - I don't know how to get them to emit an error
  19. tapTest.test "emit errors from stream errors", (test) ->
  20. test.plan 1
  21. gulp.src getPath 'tests/fixtures/' + 'js.js'
  22. .pipe tap (file, t) ->
  23. test.doesNotThrow t.through.bind(null, gulp.src, ['non-existing.txt'])###