forked from babel/gulp-babel
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
51 lines (42 loc) · 1.17 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
'use strict';
var assert = require('assert');
var gutil = require('gulp-util');
var sourceMaps = require('gulp-sourcemaps');
var to5 = require('./');
it('should transpile ES6 to ES5', function (cb) {
var stream = to5();
stream.on('data', function (file) {
assert(/var foo/.test(file.contents.toString()), file.contents.toString());
assert.equal(file.relative, 'fixture.js');
});
stream.on('end', cb);
stream.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture.es6',
contents: new Buffer('let foo;')
}));
stream.end();
});
it('should generate source maps', function (cb) {
var init = sourceMaps.init();
var write = sourceMaps.write();
init
.pipe(to5())
.pipe(write);
write.on('data', function (file) {
assert.deepEqual(file.sourceMap.sources, ['fixture.js']);
var contents = file.contents.toString();
assert(/function/.test(contents));
assert(/sourceMappingURL/.test(contents));
cb();
});
init.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture.js',
contents: new Buffer('[].map(v => v + 1)'),
sourceMap: ''
}));
init.end();
});