forked from olohmann/gulp-filenames-to-json
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
34 lines (26 loc) · 876 Bytes
/
test.js
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
'use strict';
var assert = require('assert');
var gutil = require('gulp-util');
var filenamesToJson = require('./');
it('should create a JSON file with an array of all piped files', function (cb) {
var stream = filenamesToJson();
stream.on('data', function (file) {
assert(file.path === 'files.json', 'expected the default file name to be "files.json"');
var fileArray = JSON.parse(file.contents.toString());
assert(fileArray.length === 2);
assert(fileArray[0] === 'file1.js');
assert(fileArray[1] === 'foo/file2.js');
});
stream.on('end', cb);
stream.write(new gutil.File({
base: __dirname,
path: __dirname + '/file1.js',
contents: new Buffer('')
}));
stream.write(new gutil.File({
base: __dirname,
path: __dirname + '/foo/file2.js',
contents: new Buffer('')
}));
stream.end();
});