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

update tests for exports name options

hugh-obrien 8 лет назад
Родитель
Сommit
b02eea1e7e
1 измененных файлов с 13 добавлено и 7 удалено
  1. 13 7
      services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee

+ 13 - 7
services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee

@@ -27,6 +27,11 @@ describe 'ExportsHandler', ->
 		@project_history_id = 987
 		@project_history_id = 987
 		@user_id = "user-id-456"
 		@user_id = "user-id-456"
 		@brand_variation_id = 789
 		@brand_variation_id = 789
+		@export_params = {
+			project_id: @project_id,
+			brand_variation_id: @brand_variation_id,
+			user_id: @user_id
+		}
 		@callback = sinon.stub()
 		@callback = sinon.stub()
 
 
 	describe 'exportProject', ->
 	describe 'exportProject', ->
@@ -35,13 +40,13 @@ describe 'ExportsHandler', ->
 			@response_body = {iAmAResponseBody: true}
 			@response_body = {iAmAResponseBody: true}
 			@ExportsHandler._buildExport = sinon.stub().yields(null, @export_data)
 			@ExportsHandler._buildExport = sinon.stub().yields(null, @export_data)
 			@ExportsHandler._requestExport = sinon.stub().yields(null, @response_body)
 			@ExportsHandler._requestExport = sinon.stub().yields(null, @response_body)
-			@ExportsHandler.exportProject @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+			@ExportsHandler.exportProject @export_params, (error, export_data) =>
 				@callback(error, export_data)
 				@callback(error, export_data)
 				done()
 				done()
 
 
 		it "should build the export", ->
 		it "should build the export", ->
 			@ExportsHandler._buildExport
 			@ExportsHandler._buildExport
-			.calledWith(@project_id, @user_id, @brand_variation_id)
+			.calledWith(@export_params)
 			.should.equal true
 			.should.equal true
 
 
 		it "should request the export", ->
 		it "should request the export", ->
@@ -76,7 +81,7 @@ describe 'ExportsHandler', ->
 
 
 		describe "when all goes well", ->
 		describe "when all goes well", ->
 			beforeEach (done) ->
 			beforeEach (done) ->
-				@ExportsHandler._buildExport @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
 					@callback(error, export_data)
 					@callback(error, export_data)
 					done()
 					done()
 
 
@@ -104,10 +109,11 @@ describe 'ExportsHandler', ->
 				@callback.calledWith(null, expected_export_data)
 				@callback.calledWith(null, expected_export_data)
 				.should.equal true
 				.should.equal true
 
 
+
 		describe "when project is not found", ->
 		describe "when project is not found", ->
 			beforeEach (done) ->
 			beforeEach (done) ->
 				@ProjectGetter.getProject = sinon.stub().yields(new Error("project not found"))
 				@ProjectGetter.getProject = sinon.stub().yields(new Error("project not found"))
-				@ExportsHandler._buildExport @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
 					@callback(error, export_data)
 					@callback(error, export_data)
 					done()
 					done()
 
 
@@ -118,7 +124,7 @@ describe 'ExportsHandler', ->
 		describe "when project has no root doc", ->
 		describe "when project has no root doc", ->
 			beforeEach (done) ->
 			beforeEach (done) ->
 				@ProjectLocator.findRootDoc = sinon.stub().yields(null, [null, null])
 				@ProjectLocator.findRootDoc = sinon.stub().yields(null, [null, null])
-				@ExportsHandler._buildExport @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
 					@callback(error, export_data)
 					@callback(error, export_data)
 					done()
 					done()
 
 
@@ -129,7 +135,7 @@ describe 'ExportsHandler', ->
 		describe "when user is not found", ->
 		describe "when user is not found", ->
 			beforeEach (done) ->
 			beforeEach (done) ->
 				@UserGetter.getUser = sinon.stub().yields(new Error("user not found"))
 				@UserGetter.getUser = sinon.stub().yields(new Error("user not found"))
-				@ExportsHandler._buildExport @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
 					@callback(error, export_data)
 					@callback(error, export_data)
 					done()
 					done()
 
 
@@ -140,7 +146,7 @@ describe 'ExportsHandler', ->
 		describe "when project history request fails", ->
 		describe "when project history request fails", ->
 			beforeEach (done) ->
 			beforeEach (done) ->
 				@ExportsHandler._requestVersion = sinon.stub().yields(new Error("project history call failed"))
 				@ExportsHandler._requestVersion = sinon.stub().yields(new Error("project history call failed"))
-				@ExportsHandler._buildExport @project_id, @user_id, @brand_variation_id, (error, export_data) =>
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
 					@callback(error, export_data)
 					@callback(error, export_data)
 					done()
 					done()