overleaf/services/web/test/unit/coffee/Institutions/InstitutionsManagerTests.coffee

31 lines
1.1 KiB
CoffeeScript
Raw Normal View History

2018-07-10 21:53:06 +00:00
should = require('chai').should()
SandboxedModule = require('sandboxed-module')
path = require('path')
sinon = require('sinon')
modulePath = path.join __dirname, "../../../../app/js/Features/Institutions/InstitutionsManager"
describe "InstitutionsManager", ->
beforeEach ->
@institutionId = 123
@logger = log: ->
@getInstitutionAffiliations = sinon.stub()
@refreshFeatures = sinon.stub().yields()
@InstitutionsManager = SandboxedModule.require modulePath, requires:
'logger-sharelatex': @logger
'./InstitutionsAPI':
getInstitutionAffiliations: @getInstitutionAffiliations
'../Subscription/FeaturesUpdater':
refreshFeatures: @refreshFeatures
describe 'upgradeInstitutionUsers', ->
it 'refresh all users Features', (done) ->
affiliations = [
{ user_id: '123abc123abc123abc123abc' }
{ user_id: '456def456def456def456def' }
]
@getInstitutionAffiliations.yields(null, affiliations)
@InstitutionsManager.upgradeInstitutionUsers @institutionId, (error) =>
should.not.exist(error)
sinon.assert.calledTwice(@refreshFeatures)
done()