"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 (file) { 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 logFileFunction = function (file) { let done = Q.defer(); console.log(file.contents); if (typeof file.contents !== 'undefined') { } else { throw new Error('file.contents not present'); } 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(logFileFunction, '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 () { let done = Q.defer(); beautylog.log('nextStep'); done.resolve(); return done.promise; })) .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,eyJ2ZXJzaW9uIjozLCJmaWxlIjoidGVzdC5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbInRlc3QudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IjtBQUFBLHdCQUFxQjtBQUNyQixJQUFJLElBQUksR0FBRyxPQUFPLENBQUMsTUFBTSxDQUFDLENBQUE7QUFDMUIseUNBQXdDO0FBRXhDLHVDQUFzQztBQUN0QyxJQUFJLENBQUMsR0FBRyxPQUFPLENBQUMsR0FBRyxDQUFDLENBQUE7QUFFcEIsSUFBSSxVQUFVLEdBQUc7SUFDYixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7SUFDcEIsU0FBUyxDQUFDLEdBQUcsQ0FBQyxtQkFBbUIsQ0FBQyxDQUFBO0lBQ2xDLElBQUksQ0FBQyxPQUFPLEVBQUUsQ0FBQTtJQUNkLE1BQU0sQ0FBQyxJQUFJLENBQUMsT0FBTyxDQUFBO0FBQ3ZCLENBQUMsQ0FBQTtBQUNELElBQUksV0FBVyxHQUFHLFVBQVUsSUFBSztJQUM3QixJQUFJLElBQUksR0FBRyxDQUFDLENBQUMsS0FBSyxFQUFFLENBQUE7SUFDcEIsU0FBUyxDQUFDLEVBQUUsQ0FBQyxvQkFBb0IsQ0FBQyxDQUFBO0lBQ2xDLElBQUksQ0FBQyxPQUFPLE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