gulp-browser/test/test.ts

75 lines
1.8 KiB
TypeScript
Raw Normal View History

2018-03-14 23:33:43 +00:00
import * as beautylog from 'beautylog';
import * as gulp from 'gulp';
import * as gulpFunction from 'gulp-function';
import * as smartq from 'smartq';
2018-03-14 23:33:43 +00:00
import { expect, tap } from 'tapbundle';
2017-07-07 16:32:37 +00:00
2018-03-14 23:33:43 +00:00
import * as gulpBrowser from '../ts/index';
2016-12-13 22:01:25 +00:00
2017-07-07 16:32:37 +00:00
tap.test('should run through smoothly', async () => {
2018-03-14 23:33:43 +00:00
let done = smartq.defer();
let stream = gulp
.src('./test/testBrowserifyNormal.js')
2017-07-07 16:32:37 +00:00
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
2018-03-14 23:33:43 +00:00
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
2016-12-13 22:01:25 +00:00
2017-07-07 16:32:37 +00:00
tap.test('should throw an error, when a module is not found', async () => {
2018-03-14 23:33:43 +00:00
let done = smartq.defer();
let d = require('domain').create();
let doneCalled = false;
d.on('error', function(error) {
2017-07-07 16:32:37 +00:00
if (!doneCalled) {
2018-03-14 23:33:43 +00:00
done.resolve();
doneCalled = true;
2017-07-07 16:32:37 +00:00
}
2018-03-14 23:33:43 +00:00
});
d.run(function() {
let stream = gulp.src('./test/testBrowserifyError.js').pipe(gulpBrowser.browserify());
});
await done.promise;
});
2016-12-13 22:01:25 +00:00
2017-07-07 16:32:37 +00:00
tap.test('should run through with an empty file', async () => {
2018-03-14 23:33:43 +00:00
let done = smartq.defer();
let stream = gulp
.src('./test/testBrowserifyEmpty.js')
2017-07-07 16:32:37 +00:00
.pipe(gulpBrowser.browserify())
.pipe(gulp.dest('./test/result/'))
2018-03-14 23:33:43 +00:00
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
2016-12-13 22:01:25 +00:00
2017-07-07 16:32:37 +00:00
tap.test('should run through work with transforms', async () => {
2018-03-14 23:33:43 +00:00
let done = smartq.defer();
2017-07-07 16:32:37 +00:00
let transforms = [
{
transform: 'babelify',
2018-03-14 23:33:43 +00:00
options: { presets: ['es2015'] }
2017-07-07 16:32:37 +00:00
}
2018-03-14 23:33:43 +00:00
];
let stream = gulp
.src('./test/testBrowserifyNormal.js')
2017-07-07 16:32:37 +00:00
.pipe(gulpBrowser.browserify(transforms))
.pipe(gulp.dest('./test/result/'))
2018-03-14 23:33:43 +00:00
.pipe(
gulpFunction.atEnd(async () => {
done.resolve();
})
);
await done.promise;
});
2017-07-07 16:32:37 +00:00
2018-03-14 23:33:43 +00:00
tap.start();