2016-02-01 02:33:33 +00:00
|
|
|
/// <reference path="typings/main.d.ts" />
|
2015-10-26 15:18:37 +00:00
|
|
|
var gulp = require("gulp");
|
2016-02-01 02:33:33 +00:00
|
|
|
var gulpFunction = require("../index.js");
|
|
|
|
var beautylog = require("beautylog");
|
2016-02-14 17:36:34 +00:00
|
|
|
var Q = require("q");
|
2015-10-26 15:18:37 +00:00
|
|
|
|
|
|
|
var myFunction = function () {
|
2016-02-14 17:36:34 +00:00
|
|
|
var done = Q.defer()
|
2016-02-12 04:36:23 +00:00
|
|
|
beautylog.log("Function executed");
|
2016-02-14 17:36:34 +00:00
|
|
|
done.resolve();
|
|
|
|
return done.promise;
|
2016-02-12 04:36:23 +00:00
|
|
|
};
|
|
|
|
var myFunction2 = function () {
|
2016-02-14 17:36:34 +00:00
|
|
|
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;
|
2016-02-01 02:33:33 +00:00
|
|
|
};
|
2015-10-26 15:18:37 +00:00
|
|
|
|
2016-02-01 02:33:33 +00:00
|
|
|
describe("gulpFunction",function(){
|
2016-02-14 17:36:34 +00:00
|
|
|
it("should run through smoothly with " + "'forEach'".blue,function(done){
|
2016-02-12 04:36:23 +00:00
|
|
|
gulp.src('./test/*.md')
|
|
|
|
.pipe(gulpFunction(myFunction,'forEach'))
|
|
|
|
.pipe(gulp.dest("./test/result/"));
|
2016-02-14 17:36:34 +00:00
|
|
|
|
2016-02-12 04:36:23 +00:00
|
|
|
gulp.src('./test/*.md')
|
2016-02-14 17:36:34 +00:00
|
|
|
.pipe(gulpFunction([myFunction2,myFunction3],'forEach'))
|
|
|
|
.pipe(gulp.dest("./test/result/"))
|
|
|
|
.pipe(gulpFunction(done,"atEnd"));
|
2016-02-12 04:36:23 +00:00
|
|
|
|
|
|
|
});
|
|
|
|
|
2016-02-14 17:36:34 +00:00
|
|
|
it("should run through smoothly with " + "'atEnd'".blue,function(done){
|
2016-02-12 04:36:23 +00:00
|
|
|
gulp.src('./test/*.md')
|
|
|
|
.pipe(gulpFunction(myFunction,'atEnd'))
|
|
|
|
.pipe(gulp.dest("./test/result/"));
|
2016-02-14 17:36:34 +00:00
|
|
|
|
2016-02-12 04:36:23 +00:00
|
|
|
gulp.src('./test/*.md')
|
2016-02-14 17:36:34 +00:00
|
|
|
.pipe(gulpFunction([myFunction2,myFunction3],'atEnd'))
|
|
|
|
.pipe(gulp.dest("./test/result/"))
|
|
|
|
.pipe(gulpFunction(done,"atEnd"));
|
2016-02-01 02:33:33 +00:00
|
|
|
});
|
2015-10-26 15:18:37 +00:00
|
|
|
});
|
2016-02-01 02:33:33 +00:00
|
|
|
|