Update docupdaterhandler tests.

This commit is contained in:
Paulo Reis 2017-05-18 15:04:12 +01:00
parent 04585c59be
commit b0b75e2ebb

View file

@ -252,7 +252,7 @@ describe 'DocumentUpdaterHandler', ->
.calledWith(new Error("doc updater returned failure status code: 500")) .calledWith(new Error("doc updater returned failure status code: 500"))
.should.equal true .should.equal true
describe "acceptChange", -> describe "acceptChanges", ->
beforeEach -> beforeEach ->
@change_id = "mock-change-id-1" @change_id = "mock-change-id-1"
@callback = sinon.stub() @callback = sinon.stub()
@ -260,11 +260,14 @@ describe 'DocumentUpdaterHandler', ->
describe "successfully", -> describe "successfully", ->
beforeEach -> beforeEach ->
@request.post = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body) @request.post = sinon.stub().callsArgWith(1, null, {statusCode: 200}, @body)
@handler.acceptChange @project_id, @doc_id, @change_id, @callback @handler.acceptChanges @project_id, @doc_id, [ @change_id ], @callback
it 'should accept the change in the document updater', -> it 'should accept the change in the document updater', ->
url = "#{@settings.apis.documentupdater.url}/project/#{@project_id}/doc/#{@doc_id}/change/#{@change_id}/accept" req =
@request.post.calledWith(url).should.equal true url: "#{@settings.apis.documentupdater.url}/project/#{@project_id}/doc/#{@doc_id}/change/accept"
json:
change_ids: [ @change_id ]
@request.post.calledWith(req).should.equal true
it "should call the callback", -> it "should call the callback", ->
@callback.calledWith(null).should.equal true @callback.calledWith(null).should.equal true
@ -272,7 +275,7 @@ describe 'DocumentUpdaterHandler', ->
describe "when the document updater API returns an error", -> describe "when the document updater API returns an error", ->
beforeEach -> beforeEach ->
@request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null) @request.post = sinon.stub().callsArgWith(1, @error = new Error("something went wrong"), null, null)
@handler.acceptChange @project_id, @doc_id, @change_id, @callback @handler.acceptChanges @project_id, @doc_id, [ @change_id ], @callback
it "should return an error to the callback", -> it "should return an error to the callback", ->
@callback.calledWith(@error).should.equal true @callback.calledWith(@error).should.equal true
@ -280,7 +283,7 @@ describe 'DocumentUpdaterHandler', ->
describe "when the document updater returns a failure error code", -> describe "when the document updater returns a failure error code", ->
beforeEach -> beforeEach ->
@request.post = sinon.stub().callsArgWith(1, null, { statusCode: 500 }, "") @request.post = sinon.stub().callsArgWith(1, null, { statusCode: 500 }, "")
@handler.acceptChange @project_id, @doc_id, @change_id, @callback @handler.acceptChanges @project_id, @doc_id, [ @change_id ], @callback
it "should return the callback with an error", -> it "should return the callback with an error", ->
@callback @callback