-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest.js
51 lines (41 loc) · 1.29 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
var assert = require('assert');
var gutil = require('gulp-util');
var sourceMaps = require('gulp-sourcemaps');
var regexpu = require('./index.js');
it('should transpile ES6 regex to ES5 with regexpu', function(callback) {
var stream = regexpu();
stream.on('data', function(file) {
assert(/\\uD834/.test(file.contents.toString()));
assert.equal(file.relative, 'fixture.js');
});
stream.on('end', callback);
stream.write(new gutil.File({
'cwd': __dirname,
'base': __dirname + '/fixture',
'path': __dirname + '/fixture/fixture.js',
'contents': new Buffer('var x = /[\\u{1D306}-\\u{1D308}]/u;')
}));
stream.end();
});
it('should generate source maps', function(callback) {
var init = sourceMaps.init();
var write = sourceMaps.write();
init
.pipe(regexpu())
.pipe(write);
write.on('data', function(file) {
assert.equal(file.sourceMap.mappings, 'AAAA,CAAC,CAAC,EAAE,EAAE,6BAA0B');
var contents = file.contents.toString();
assert(/\\uD834/.test(contents));
assert(/sourceMappingURL=data:application\/json;base64/.test(contents));
callback();
});
init.write(new gutil.File({
'cwd': __dirname,
'base': __dirname + '/fixture',
'path': __dirname + '/fixture/fixture.js',
'contents': new Buffer('var x = /[\\u{1D306}-\\u{1D308}]/u;'),
'sourceMap': ''
}));
init.end();
});