102 lines
8.2 KiB
JavaScript
102 lines
8.2 KiB
JavaScript
"use strict";
|
|
require("typings-test");
|
|
let gulp = require('gulp');
|
|
const index_1 = require("../dist/index");
|
|
const beautylog = require("beautylog");
|
|
let Q = require('q');
|
|
let myFunction = function () {
|
|
let done = Q.defer();
|
|
beautylog.log('Function executed');
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let myFunction2 = function () {
|
|
let done = Q.defer();
|
|
beautylog.ok('Function2 executed');
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let myFunction3 = function () {
|
|
let done = Q.defer();
|
|
beautylog.success('Function3 executed');
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let beforeFunction = function () {
|
|
let done = Q.defer();
|
|
beautylog.success('beforeFunction executed');
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let middleFunctionRun = false;
|
|
let middleFunction = function () {
|
|
let done = Q.defer();
|
|
beautylog.success('middleFunction executed');
|
|
setTimeout(function () {
|
|
beautylog.log('timeout fired');
|
|
middleFunctionRun = true;
|
|
done.resolve();
|
|
}, 500);
|
|
return done.promise;
|
|
};
|
|
let afterFunction = function () {
|
|
let done = Q.defer();
|
|
beautylog.success('afterFunction executed');
|
|
done.resolve();
|
|
return done.promise;
|
|
};
|
|
let timeoutFunction = function () {
|
|
let done = Q.defer();
|
|
setTimeout(function () {
|
|
beautylog.log('largeTimeout fired');
|
|
done.resolve();
|
|
}, 2000);
|
|
return done.promise;
|
|
};
|
|
describe('gulpFunction', function () {
|
|
it('should run through smoothly with ' + "'forEach'", function (done) {
|
|
gulp.src('./test/*.md')
|
|
.pipe(index_1.default(myFunction, 'forEach'))
|
|
.pipe(gulp.dest('./test/result/'));
|
|
gulp.src('./test/*.md')
|
|
.pipe(index_1.default([myFunction2, myFunction3], 'forEach'))
|
|
.pipe(gulp.dest('./test/result/'))
|
|
.pipe(index_1.default(done, 'atEnd'));
|
|
});
|
|
it('should run through smoothly with ' + "'atEnd'", function (done) {
|
|
gulp.src('./test/*.md')
|
|
.pipe(index_1.default(myFunction, 'atEnd'))
|
|
.pipe(gulp.dest('./test/result/'));
|
|
gulp.src('./test/*.md')
|
|
.pipe(index_1.default([myFunction2, myFunction3], 'atEnd'))
|
|
.pipe(gulp.dest('./test/result/'))
|
|
.pipe(index_1.default(done, 'atEnd'));
|
|
});
|
|
it('should run through smoothly once with ' + "'atFirst'", function (done) {
|
|
gulp.src('./test/*.md')
|
|
.pipe(index_1.default([myFunction2, myFunction3], 'forFirst'))
|
|
.pipe(gulp.dest('./test/result/'))
|
|
.pipe(index_1.default(done, 'atEnd'));
|
|
});
|
|
it('should run in order', function (done) {
|
|
this.timeout(5000);
|
|
let stream = gulp.src('./test/*.md')
|
|
.pipe(index_1.default([beforeFunction, middleFunction, middleFunction], 'atEnd'))
|
|
.pipe(index_1.default(function () {
|
|
beautylog.log('stream progressed');
|
|
let done2 = Q.defer();
|
|
done2.resolve();
|
|
return done2.promise;
|
|
}, 'forEach'))
|
|
.pipe(index_1.default(function () {
|
|
beautylog.log('nextStep');
|
|
}))
|
|
.pipe(index_1.default(afterFunction, 'atEnd'))
|
|
.pipe(index_1.default(timeoutFunction, 'atEnd'));
|
|
stream.on('finish', function () {
|
|
beautylog.info('stream finished');
|
|
done();
|
|
});
|
|
});
|
|
});
|
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUE7QUFDMUIseUNBQXdDO0FBRXhDLHVDQUFzQztBQUN0QyxJQUFJLENBQUMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUE7QUFFcEIsSUFBSSxVQUFVLEdBQUc7SUFDYixJQUFJLElBQUksR0FB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