From 300449bfb0527ca9c9315cd7dfbb30bad4caafa9 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Fri, 13 May 2016 14:59:05 -0700 Subject: [PATCH] add test for missing index result --- test/src/worker.js | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/test/src/worker.js b/test/src/worker.js index 9c3f277..69f35a2 100644 --- a/test/src/worker.js +++ b/test/src/worker.js @@ -165,6 +165,24 @@ describe('Worker class', function () { .then(() => { done(); }) .catch(() => done(new Error('should not reject'))); }); + + it('should return an empty array on missing index', function (done) { + searchStub = sinon.stub(mockQueue.client, 'search', () => Promise.reject({ + status: 404 + })); + worker = new Worker(mockQueue, 'test', noop); + worker._getPendingJobs() + .then((res) => { + try { + expect(res).to.be.an(Array); + expect(res).to.have.length(0); + done(); + } catch (e) { + done(e); + } + }) + .catch(() => done(new Error('should not reject'))); + }); }); describe('query parameters', function () {