From 5987d6d79cbe9b000afb2ad5d2b6dceca3162fb8 Mon Sep 17 00:00:00 2001 From: Michael Walker Date: Fri, 2 Feb 2018 10:08:29 +0000 Subject: [PATCH] Add unit tests for failing history API --- .../History/HistoryControllerTests.coffee | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/services/web/test/unit/coffee/History/HistoryControllerTests.coffee b/services/web/test/unit/coffee/History/HistoryControllerTests.coffee index 06f2630b6b..7dc3c88169 100644 --- a/services/web/test/unit/coffee/History/HistoryControllerTests.coffee +++ b/services/web/test/unit/coffee/History/HistoryControllerTests.coffee @@ -182,3 +182,20 @@ describe "HistoryController", -> it "should return the data with users to the client", -> @res.json.calledWith(@data_with_users).should.equal true + + describe "proxyToHistoryApiAndInjectUserDetails (with the history API failing)", -> + beforeEach -> + @req = { url: "/mock/url", method: "POST", useProjectHistory: true } + @res = { json: sinon.stub() } + @next = sinon.stub() + @request.yields(null, {statusCode: 500}, @data = "mock-data") + @HistoryManager.injectUserDetails = sinon.stub().yields(null, @data_with_users = "mock-injected-data") + @HistoryController.proxyToHistoryApiAndInjectUserDetails @req, @res, @next + + it "should not inject the user data", -> + @HistoryManager.injectUserDetails + .calledWith(@data) + .should.equal false + + it "should not return the data with users to the client", -> + @res.json.calledWith(@data_with_users).should.equal false