Unit test brand variation id.

This commit is contained in:
Paulo Reis
2018-10-10 14:09:47 +01:00
parent 29787c42c5
commit 901fb0fc1e
4 changed files with 67 additions and 5 deletions
@@ -4,7 +4,7 @@ should = chai.should()
modulePath = "../../../../app/js/Features/Project/ProjectOptionsHandler.js"
SandboxedModule = require('sandboxed-module')
describe 'creating a project', ->
describe 'ProjectOptionsHandler', ->
project_id = "4eecaffcbffa66588e000008"
beforeEach ->
@@ -77,3 +77,23 @@ describe 'creating a project', ->
@projectModel.update.called.should.equal true
done()
@projectModel.update.args[0][3]()
describe "setting the brandVariationId", ->
it 'should perform and update on mongo', (done)->
@handler.setBrandVariationId project_id, "123", (err)=>
args = @projectModel.update.args[0]
args[0]._id.should.equal project_id
args[1].brandVariationId.should.equal "123"
done()
@projectModel.update.args[0][3]()
it 'should not perform and update on mongo if there is no brand variation', (done)->
@handler.setBrandVariationId project_id, null, (err)=>
@projectModel.update.called.should.equal false
done()
it 'should not perform and update on mongo if brand variation is an empty string', (done)->
@handler.setBrandVariationId project_id, "", (err)=>
@projectModel.update.called.should.equal false
done()