gulp-browser/test/test.js

56 lines
4.5 KiB
JavaScript
Raw Normal View History

2016-06-03 18:11:17 +00:00
"use strict";
require("typings-test");
2016-12-13 22:01:25 +00:00
const gulp = require("gulp");
const gulpBrowser = require("../dist/index.js");
const gulpFunction = require("gulp-function");
const q = require("q");
describe('gulpBrowser', function () {
describe('.browserify', function () {
it('should run through smoothly', function (done) {
2016-02-09 19:49:12 +00:00
this.timeout(30000);
2016-12-13 22:01:25 +00:00
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(() => {
let done2 = q.defer();
done();
done2.resolve();
return done2.promise;
}));
});
2016-12-13 22:01:25 +00:00
it('should throw an error, when a module is not found', function (done) {
2016-07-26 16:15:03 +00:00
let d = require('domain').create();
let doneCalled = false;
2016-12-13 22:01:25 +00:00
d.on('error', function (error) {
if (!doneCalled) {
done();
doneCalled = true;
}
});
d.run(function () {
2016-12-13 22:01:25 +00:00
let stream = gulp.src('./test/testBrowserifyError.js')
.pipe(gulpBrowser.browserify());
2016-02-01 02:10:58 +00:00
});
});
2016-12-13 22:01:25 +00:00
it('should run through with an empty file', function (done) {
let stream = gulp.src('./test/testBrowserifyEmpty.js')
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(done));
2016-02-01 02:10:58 +00:00
});
2016-12-13 22:01:25 +00:00
it('should run through work with transforms', function (done) {
2016-06-03 18:57:10 +00:00
this.timeout(30000);
2016-07-26 16:15:03 +00:00
let transforms = [
2016-06-03 18:57:10 +00:00
{
2016-12-13 22:01:25 +00:00
transform: 'babelify',
options: { presets: ['es2015'] }
2016-06-03 18:57:10 +00:00
}
];
2016-12-13 22:01:25 +00:00
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify(transforms))
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(done));
2016-06-03 18:57:10 +00:00
});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