now accepts promises as return of supplied functions
This commit is contained in:
6
test/test.d.ts
vendored
6
test/test.d.ts
vendored
@ -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;
|
||||
|
29
test/test.js
29
test/test.js
@ -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"));
|
||||
});
|
||||
});
|
||||
|
Reference in New Issue
Block a user