I am trying to stub for
ElasticSerach Node.js clientclient = new elasticsearch.Client()
#.get can be stubbed easily (in
beforeEach - section on top
describe - level) with:
var getStub = sinon.stub(client, 'get')
getStub
.withArgs({
index: 'database',
type: 'table',
id: 'notExistingId'
})
.yields(null, {
found: false
})
But I am not sure how can I stub
update properly:.
As expected this code can not work:
var updateStub = sinon.stub(client, 'update')
.withArgs({
index: 'database',
type: 'table',
id: 'NonExistingId', // Only this parameter is important
body: {} // I want to create stub for any body content, but stub is created only for empty
})
.yields(null, {
found: false
})
Or this is wrong way/test anti-pattern?
Should I create without testCase-specific stub (in
it section) without
withArgs ?