gulp-browser/test/test.js

56 lines
4.5 KiB
JavaScript

"use strict";
require("typings-test");
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) {
this.timeout(30000);
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;
}));
});
it('should throw an error, when a module is not found', function (done) {
let d = require('domain').create();
let doneCalled = false;
d.on('error', function (error) {
if (!doneCalled) {
done();
doneCalled = true;
}
});
d.run(function () {
let stream = gulp.src('./test/testBrowserifyError.js')
.pipe(gulpBrowser.browserify());
});
});
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));
});
it('should run through work with transforms', function (done) {
this.timeout(30000);
let transforms = [
{
transform: 'babelify',
options: { presets: ['es2015'] }
}
];
let stream = gulp.src('./test/testBrowserifyNormal.js')
.pipe(gulpBrowser.browserify(transforms))
.pipe(gulp.dest('./test/result/'))
.pipe(gulpFunction.atEnd(done));
});
});
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUdyQiw2QkFBNEI7QUFDNUIsZ0RBQStDO0FBQy9DLDhDQUE2QztBQUc3Qyx1QkFBc0I7QUFHdEIsUUFBUSxDQUFDLGFBQWEsRUFBRTtJQUNwQixRQUFRLENBQUMsYUFBYSxFQUFFO1FBQ3BCLEVBQUUsQ0FBQyw2QkFBNkIsRUFBRSxVQUFVLElBQUk7WUFD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