Просмотр исходного кода

Add unit tests for failing history API

Michael Walker 8 лет назад
Родитель
Сommit
5987d6d79c
1 измененных файлов с 17 добавлено и 0 удалено
  1. 17 0
      services/web/test/unit/coffee/History/HistoryControllerTests.coffee

+ 17 - 0
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