未验证 提交 14d4d0f1 编写于 作者: S Saurav Azad 提交者: GitHub

Improving tests case coverage (#1754)

* Adding test case when invalid callback is provided to each ()

* adding nyc  ignore block

* Adding new test cases for drain to be called if empty data is pushed
上级 200cc008
......@@ -2,12 +2,15 @@ import wrapAsync from './wrapAsync';
export default function consoleFunc(name) {
return (fn, ...args) => wrapAsync(fn)(...args, (err, ...resultArgs) => {
/* istanbul ignore else */
if (typeof console === 'object') {
/* istanbul ignore else */
if (err) {
/* istanbul ignore else */
if (console.error) {
console.error(err);
}
} else if (console[name]) {
} else if (console[name]) { /* istanbul ignore else */
resultArgs.forEach(x => console[name](x));
}
}
......
......@@ -96,6 +96,15 @@ describe("each", () => {
async.each([1], eachNoCallbackIteratee.bind(this, done));
});
it('each no callback', async (done) => {
try {
async.each([1], 'INVALID_CALL_BACK', () => {});
} catch(err) {
expect(err.message).to.equal('expected a function')
done()
}
});
it('eachSeries', function(done) {
var args = [];
async.eachSeries([1,3,2], eachIteratee.bind(this, args), (err) => {
......
......@@ -49,8 +49,15 @@ describe('priorityQueue', () => {
]);
expect(q.concurrency).to.equal(1);
expect(q.length()).to.equal(0);
done();
q.push([])
expect(q.length()).to.equal(0)
done()
});
try {
q.push(5, 5, 'NOT_A_FUNCTION')
} catch(e) {
expect(e.message).to.equal('task callback must be a function')
}
});
it('concurrency', (done) => {
......@@ -276,4 +283,3 @@ describe('priorityQueue', () => {
q.push([], 1, () => {});
});
});
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册