test custom first and last name for exports

This commit is contained in:
hugh-obrien
2018-06-04 13:16:21 +01:00
parent b02eea1e7e
commit 54ce196500
2 changed files with 31 additions and 2 deletions
@@ -14,8 +14,8 @@ module.exports =
}
if req.body && req.body.firstName && req.body.firstName
export_params.first_name = req.body.firstName
export_params.last_name = req.body.lastName
export_params.first_name = req.body.firstName.trim()
export_params.last_name = req.body.lastName.trim()
ExportsHandler.exportProject export_params, (err, export_data) ->
return next(err) if err?
@@ -109,6 +109,35 @@ describe 'ExportsHandler', ->
@callback.calledWith(null, expected_export_data)
.should.equal true
describe "when we send replacement user first and last name", ->
beforeEach (done) ->
@custom_first_name = "FIRST"
@custom_last_name = "LAST"
@export_params.first_name = @custom_first_name
@export_params.last_name = @custom_last_name
@ExportsHandler._buildExport @export_params, (error, export_data) =>
@callback(error, export_data)
done()
it "should send the data from the user input", ->
expected_export_data =
project:
id: @project_id
rootDocPath: @rootDocPath
historyId: @project_history_id
historyVersion: @historyVersion
user:
id: @user_id
firstName: @custom_first_name
lastName: @custom_last_name
email: @user.email
orcidId: null
destination:
brandVariationId: @brand_variation_id
options:
callbackUrl: null
@callback.calledWith(null, expected_export_data)
.should.equal true
describe "when project is not found", ->
beforeEach (done) ->