forked from sindresorhus/gulp-traceur
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathtest.js
68 lines (55 loc) · 1.64 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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
'use strict';
var assert = require('assert');
var fs = require('fs');
var gutil = require('gulp-util');
var traceur = require('./index');
it('should transpile with Traceur', function (cb) {
var stream = traceur({blockBinding: true});
stream.on('data', function (file) {
assert(/Foo/.test(file.contents.toString()));
cb();
});
stream.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture.js',
contents: new Buffer('import {Foo} from \'./foo\';')
}));
});
it('should pass syntax errors', function (cb) {
var stream = traceur();
stream.on('error', function (err) {
assert(/Semi-colon expected/.test(err.message));
cb();
});
stream.write(new gutil.File({
cwd: __dirname,
base: __dirname + '/fixture',
path: __dirname + '/fixture/fixture.js',
contents: new Buffer('cons x = 1;')
}));
});
it('should expose the Traceur runtime path', function () {
assert(typeof traceur.RUNTIME_PATH === 'string');
assert(traceur.RUNTIME_PATH.length > 0);
});
it('should support Source Map', function (cb) {
var stream = traceur({sourceMap: true});
stream.on('data', function (file) {
if (/\.map$/.test(file.path)) {
assert(/\"version":3/.test(file.contents.toString()));
assert.equal(file.relative, 'fixture.js.map');
return;
}
assert(/sourceMappingURL=fixture\.js\.map/.test(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.js',
contents: new Buffer('import {Foo} from \'./foo\';')
}));
stream.end();
});