now accepts promises as return of supplied functions

This commit is contained in:
2016-02-14 18:36:34 +01:00
parent ac9305c480
commit 6e55ed3162
7 changed files with 133 additions and 62 deletions

6
test/test.d.ts vendored
View File

@ -2,5 +2,7 @@
declare var gulp: any;
declare var gulpFunction: any;
declare var beautylog: any;
declare var myFunction: () => void;
declare var myFunction2: () => void;
declare var Q: any;
declare var myFunction: () => any;
declare var myFunction2: () => any;
declare var myFunction3: () => any;

View File

@ -4,27 +4,42 @@
var gulp = require("gulp");
var gulpFunction = require("../index.js");
var beautylog = require("beautylog");
var Q = require("q");
var myFunction = function () {
var done = Q.defer();
beautylog.log("Function executed");
done.resolve();
return done.promise;
};
var myFunction2 = function () {
beautylog.log("Function2 executed");
var done = Q.defer();
beautylog.ok("Function2 executed");
done.resolve();
return done.promise;
};
var myFunction3 = function () {
var done = Q.defer();
beautylog.success("Function3 executed");
done.resolve();
return done.promise;
};
describe("gulpFunction", function () {
it("should run through smoothly with " + "'forEach'".blue, function () {
it("should run through smoothly with " + "'forEach'".blue, function (done) {
gulp.src('./test/*.md')
.pipe(gulpFunction(myFunction, 'forEach'))
.pipe(gulp.dest("./test/result/"));
gulp.src('./test/*.md')
.pipe(gulpFunction([myFunction, myFunction2], 'forEach'))
.pipe(gulp.dest("./test/result/"));
.pipe(gulpFunction([myFunction2, myFunction3], 'forEach'))
.pipe(gulp.dest("./test/result/"))
.pipe(gulpFunction(done, "atEnd"));
});
it("should run through smoothly with " + "'atEnd'".blue, function () {
it("should run through smoothly with " + "'atEnd'".blue, function (done) {
gulp.src('./test/*.md')
.pipe(gulpFunction(myFunction, 'atEnd'))
.pipe(gulp.dest("./test/result/"));
gulp.src('./test/*.md')
.pipe(gulpFunction([myFunction, myFunction2], 'atEnd'))
.pipe(gulp.dest("./test/result/"));
.pipe(gulpFunction([myFunction2, myFunction3], 'atEnd'))
.pipe(gulp.dest("./test/result/"))
.pipe(gulpFunction(done, "atEnd"));
});
});