469MS

MS

14

Suites

23

Tests

23

Passed

0

Failed

0

Pending

0% Pending
100% Passing

The `task` method

/test/pro-gulp.js
  • 2 ms
  • 2
  • 2
  • 0
  • 0

Tests

should behave _like_ a getter when called with only one argument

1 ms
var tasks = {
name: function () {}
};
proGulp.__set__("tasks", tasks);
proGulp.task("name").should.equal(tasks.name);

should behave _like_ a setter when called with more than one argument

1 ms
proGulp.task("name", function () {});
proGulp.task("name").should.be.of.type("function");

The function returned by the `task` method

/test/pro-gulp.js
  • 5 ms
  • 3
  • 3
  • 0
  • 0

Tests

should return a promise

2 ms
proGulp.task("name", function () {});
proGulp.task("name")().should.be.a.Promise;

should call the function(s) passed as second (and third) argument [1 function]

2 ms
var spy_0 = sinon.spy();
proGulp.task("name", spy_0);
return proGulp.task("name")().then(function () {
spy_0.called.should.equal(true);
});

should call the function(s) passed as second (and third) argument [2 functions]

1 ms
var spy_0 = sinon.spy();
var spy_1 = sinon.spy();
proGulp.task("name", spy_0, spy_1);
return proGulp.task("name")().then(function () {
spy_0.called.should.equal(true);
spy_1.called.should.equal(true);
});

The `parallel` method

/test/pro-gulp.js
  • 0 ms
  • 1
  • 1
  • 0
  • 0

Tests

should return a function

0 ms
var ret = proGulp.parallel();
ret.should.be.of.type("function");

The function returned by the `parallel` method

/test/pro-gulp.js
  • 1 ms
  • 2
  • 2
  • 0
  • 0

Tests

should return a promise

0 ms
var ret = proGulp.parallel([]);
ret().should.be.a.Promise;

should execute tasks in parallel (order does not matter)

1 ms
var spy = sinon.spy();
proGulp.task("task_0", spy);
proGulp.task("task_1", spy);
var ret = proGulp.parallel(["task_0", "task_1"]);
return ret().then(function () {
spy.calledTwice.should.equal(true);
});

The `sequence` method

/test/pro-gulp.js
  • 0 ms
  • 1
  • 1
  • 0
  • 0

Tests

should return a function

0 ms
var ret = proGulp.sequence();
ret.should.be.of.type("function");

The function returned by the `sequence` method

/test/pro-gulp.js
  • 423 ms
  • 2
  • 2
  • 0
  • 0

Tests

should return a promise

0 ms
var ret = proGulp.sequence([]);
ret().should.be.a.Promise;

should execute tasks in sequence (order does matter)

423 ms
var spies = [];
var getTime = function () {
var timestamp = process.hrtime();
return timestamp[0] * 1e9 + timestamp[1];
};
var createSpy = function (n) {
spies[n] = {};
spies[n].fn = sinon.spy(function () {
spies[n].start = getTime();
return BPromise.delay(100).then(function () {
spies[n].end = getTime();
});
});
};
createSpy(0);
createSpy(1);
createSpy(2);
createSpy(3);
proGulp.task("task_0", spies[0].fn);
proGulp.task("task_1", spies[1].fn);
proGulp.task("task_2", spies[2].fn);
proGulp.task("task_3", spies[3].fn);
var ret = proGulp.sequence([
"task_0",
"task_1",
"task_2",
"task_3"
]);
return ret().then(function () {
// Check they have been called
spies[0].fn.called.should.equal(true);
spies[1].fn.called.should.equal(true);
spies[2].fn.called.should.equal(true);
spies[3].fn.called.should.equal(true);
// Check they have been called in the right order
(spies[0].start < spies[0].end).should.equal(true);
(spies[0].end < spies[1].start).should.equal(true);
(spies[1].start < spies[1].end).should.equal(true);
(spies[1].end < spies[2].start).should.equal(true);
(spies[2].start < spies[2].end).should.equal(true);
(spies[2].end < spies[3].start).should.equal(true);
(spies[3].start < spies[3].end).should.equal(true);
});

The `log.start` function

/test/lib/log.js
  • 1 ms
  • 2
  • 2
  • 0
  • 0

Tests

should attach a Date object to the property `start` of its context

1 ms
var ctx = {};
log.start.call(ctx);
ctx.start.should.be.instanceOf(Date);

should call the `gulp-util.log` function

0 ms
log.start.call({});
util.log.calledWithMatch(/Starting/).should.equal(true);

The `log.end` function

/test/lib/log.js
  • 0 ms
  • 2
  • 2
  • 0
  • 0

Tests

should attach a Date object to the property `end` of its context

0 ms
var ctx = {
start: new Date()
};
log.end.call(ctx);
ctx.end.should.be.instanceOf(Date);

should call the `gulp-util.log` function

0 ms
log.end.call({});
util.log.calledWithMatch(/Finished/).should.equal(true);

The `promisify` function

/test/lib/promisify.js
  • 0 ms
  • 1
  • 1
  • 0
  • 0

Tests

should returned a function

0 ms
var ret = promisify();
ret.should.be.of.type("function");

The function returned by `promisify`

/test/lib/promisify.js
  • 0 ms
  • 2
  • 2
  • 0
  • 0

Tests

should invoke the function supplied to `promisify`, when called

0 ms
var spy = sinon.spy();
var fn = promisify(spy);
fn();
spy.called.should.equal(true);

should return a promise

0 ms
var spy = sinon.spy();
var fn = promisify(spy);
var ret = fn();
ret.should.be.a.Promise;

When the supplied function returns a stream, the promise returned by the wrapper

/test/lib/promisify.js
  • 2 ms
  • 2
  • 2
  • 0
  • 0

Tests

should be fulfilled when the stream ends

1 ms
var stream = new events.EventEmitter();
stream.pipe = function noop () {};
var fn = promisify(function () {
return stream;
});
var ret = fn();
stream.emit("end");
return ret.should.be.fulfilled;

should be rejected when the stream errors

1 ms
var stream = new events.EventEmitter();
stream.pipe = function noop () {};
var fn = promisify(function () {
return stream;
});
var ret = fn();
stream.emit("error");
return ret.should.be.rejected;

When the supplied function returns a promise, the promise returned by the wrapper

/test/lib/promisify.js
  • 0 ms
  • 1
  • 1
  • 0
  • 0

Tests

should be the same promise proxied through

0 ms
var promise = BPromise.resolve();
var fn = promisify(function () {
return promise;
});
var ret = fn();
ret.should.equal(promise);

When the supplied function returns a value, the promise returned by the wrapper

/test/lib/promisify.js
  • 1 ms
  • 1
  • 1
  • 0
  • 0

Tests

should be a promise wrapper around that value

1 ms
var value = {};
var fn = promisify(function () {
return value;
});
var ret = fn();
return ret.should.eventually.equal(value);

When the supplied function throws, the wrapper

/test/lib/promisify.js
  • 1 ms
  • 1
  • 1
  • 0
  • 0

Tests

should throw

1 ms
var error = new Error();
var fn = promisify(function () {
throw error;
});
fn.should.throw(error);