From 22d9ffcefe39d21db9c3cbe7a24bfdc9192fd897 Mon Sep 17 00:00:00 2001 From: Joe Fleming Date: Mon, 18 Apr 2016 16:34:03 -0700 Subject: [PATCH] better elasticsearch client fixture --- test/fixtures/elasticsearch.js | 14 +++++++++++++- test/src/job.js | 2 +- 2 files changed, 14 insertions(+), 2 deletions(-) diff --git a/test/fixtures/elasticsearch.js b/test/fixtures/elasticsearch.js index a819029..a38882f 100644 --- a/test/fixtures/elasticsearch.js +++ b/test/fixtures/elasticsearch.js @@ -1,5 +1,17 @@ +import { uniqueId } from 'lodash'; + function Client() {} -Client.prototype.index = function () {}; +Client.prototype.index = function (params) { + var shardCount = 2; + return Promise.resolve({ + _index: params.index || 'index', + _type: params.type || 'type', + _id: uniqueId('testDoc'), + _version: 1, + _shards: { total: shardCount, successful: shardCount, failed: 0 }, + created: true + }); +}; export default { Client: Client diff --git a/test/src/job.js b/test/src/job.js index 7bfc3dd..2718479 100644 --- a/test/src/job.js +++ b/test/src/job.js @@ -44,7 +44,7 @@ describe('Jobs', function () { type = 'type1'; payload = { id: '123' }; options = { timeout: 1234 }; - sinon.stub(mockQueue.client, 'index'); + sinon.spy(mockQueue.client, 'index'); }); it('should index the payload', function () {