summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSaurav Azad <3856934+sauravazad@users.noreply.github.com>2021-06-29 03:17:36 +0530
committerGitHub <noreply@github.com>2021-06-28 14:47:36 -0700
commit14d4d0f196d9a26801bb261d16105b59292bb03c (patch)
treeed2c644300a8d23902a4fbb1719b748f1cf38487
parent200cc0088e49e1e1a27cddee0428288d173f48a4 (diff)
downloadasync-14d4d0f196d9a26801bb261d16105b59292bb03c.tar.gz
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
-rw-r--r--lib/internal/consoleFunc.js5
-rw-r--r--test/each.js9
-rw-r--r--test/priorityQueue.js10
3 files changed, 21 insertions, 3 deletions
diff --git a/lib/internal/consoleFunc.js b/lib/internal/consoleFunc.js
index d2c1cb1..4ce5c9b 100644
--- a/lib/internal/consoleFunc.js
+++ b/lib/internal/consoleFunc.js
@@ -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));
}
}
diff --git a/test/each.js b/test/each.js
index eb12842..7b83476 100644
--- a/test/each.js
+++ b/test/each.js
@@ -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) => {
diff --git a/test/priorityQueue.js b/test/priorityQueue.js
index 96936fd..564a0d6 100644
--- a/test/priorityQueue.js
+++ b/test/priorityQueue.js
@@ -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, () => {});
});
});
-