File: throws.test.coffee

package info (click to toggle)
node-gulp-tap 2.0.0-3
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, forky, sid, trixie
  • size: 124 kB
  • sloc: makefile: 4; javascript: 2
file content (35 lines) | stat: -rw-r--r-- 1,055 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
process.env['NODE_ENV'] = 'development'

fs    = require 'fs'
path  = require 'path'
gulp  = require 'gulp'
tap   = require '../'
tapTest = require 'tap'


# helper function to get a path relative to the root
getPath = (rel) -> path.resolve __dirname, '..', rel

identity = (x) -> x


tapTest.test "throw errors", (test) ->

	test.plan 2

	gulp.src getPath 'tests/fixtures/' + 'js.js'
	.pipe tap (file, t) ->
		test.throws t.through.bind(null, gulp.dest, "wrong"), new TypeError("Args must be an array to `apply` to the filter")

	gulp.src getPath 'tests/fixtures/' + 'js.js'
		.pipe tap (file, t) ->
			test.throws t.through.bind(null, identity, ["right"]), {}, "should throw if supplied function doesn't return a stream'"

### Giving up due to lack of knowledge about vinyl-fs streams - I don't know how to get them to emit an error
tapTest.test "emit errors from stream errors", (test) ->

	test.plan 1

	gulp.src getPath 'tests/fixtures/' + 'js.js'
		.pipe tap (file, t) ->
			test.doesNotThrow t.through.bind(null, gulp.src, ['non-existing.txt'])###