2019-05-29 05:21:06 -04:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
|
|
|
handle-callback-err,
|
|
|
|
max-len,
|
|
|
|
no-return-assign,
|
|
|
|
no-unused-vars,
|
|
|
|
*/
|
|
|
|
// TODO: This file was created by bulk-decaffeinate.
|
|
|
|
// Fix any style issues and re-enable lint.
|
|
|
|
/*
|
|
|
|
* decaffeinate suggestions:
|
|
|
|
* DS102: Remove unnecessary code created because of implicit returns
|
|
|
|
* Full docs: https://github.com/decaffeinate/decaffeinate/blob/master/docs/suggestions.md
|
|
|
|
*/
|
|
|
|
const SandboxedModule = require('sandboxed-module')
|
|
|
|
const should = require('chai').should()
|
|
|
|
const sinon = require('sinon')
|
|
|
|
const modulePath =
|
|
|
|
'../../../../app/src/Features/Subscription/UserFeaturesUpdater'
|
|
|
|
const { assert } = require('chai')
|
|
|
|
|
|
|
|
describe('UserFeaturesUpdater', function() {
|
|
|
|
beforeEach(function() {
|
|
|
|
this.User = { update: sinon.stub().callsArgWith(2) }
|
|
|
|
return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, {
|
2019-07-15 06:33:47 -04:00
|
|
|
globals: {
|
|
|
|
console: console
|
|
|
|
},
|
2019-05-29 05:21:06 -04:00
|
|
|
requires: {
|
|
|
|
'../../models/User': {
|
|
|
|
User: this.User
|
|
|
|
},
|
|
|
|
'logger-sharelatex': {
|
|
|
|
log() {}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
|
2019-06-21 09:46:09 -04:00
|
|
|
describe('updateFeatures', () =>
|
2019-05-29 05:21:06 -04:00
|
|
|
it('should send the users features', function(done) {
|
|
|
|
const user_id = '5208dd34438842e2db000005'
|
|
|
|
this.features = { versioning: true, collaborators: 10 }
|
|
|
|
return this.UserFeaturesUpdater.updateFeatures(
|
|
|
|
user_id,
|
|
|
|
this.features,
|
|
|
|
(err, features) => {
|
|
|
|
const update = {
|
|
|
|
'features.versioning': true,
|
|
|
|
'features.collaborators': 10
|
|
|
|
}
|
|
|
|
this.User.update
|
|
|
|
.calledWith({ _id: user_id }, update)
|
|
|
|
.should.equal(true)
|
|
|
|
features.should.deep.equal(this.features)
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
|
|
|
}))
|
|
|
|
})
|