2016-12-13 22:01:25 +00:00
|
|
|
import 'typings-test'
|
2016-01-24 23:42:11 +00:00
|
|
|
|
2016-12-13 22:01:25 +00:00
|
|
|
import * as beautylog from 'beautylog'
|
|
|
|
import * as gulp from 'gulp'
|
|
|
|
import * as gulpBrowser from '../dist/index.js'
|
|
|
|
import * as gulpFunction from 'gulp-function'
|
2016-04-01 13:56:35 +00:00
|
|
|
|
2016-12-13 22:01:25 +00:00
|
|
|
import * as should from 'should'
|
|
|
|
import * as q from '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()
|
2016-04-01 13:56:35 +00:00
|
|
|
let doneCalled = false
|
2016-12-13 22:01:25 +00:00
|
|
|
d.on('error',function(error){
|
|
|
|
if (!doneCalled) {
|
|
|
|
done()
|
|
|
|
doneCalled = true
|
2016-04-01 13:56:35 +00:00
|
|
|
}
|
2016-12-13 22:01:25 +00:00
|
|
|
})
|
|
|
|
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)
|
2016-06-03 18:57:10 +00:00
|
|
|
let transforms = [
|
|
|
|
{
|
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))
|
|
|
|
})
|
|
|
|
})
|
|
|
|
})
|