mirror of
https://github.com/overleaf/overleaf.git
synced 2024-12-27 12:10:51 +00:00
31 lines
1.1 KiB
CoffeeScript
31 lines
1.1 KiB
CoffeeScript
|
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()
|