2019-05-29 05:21:06 -04:00
|
|
|
/* eslint-disable
|
|
|
|
camelcase,
|
2020-12-15 05:23:54 -05:00
|
|
|
node/handle-callback-err,
|
2019-05-29 05:21:06 -04:00
|
|
|
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 sinon = require('sinon')
|
|
|
|
const modulePath =
|
|
|
|
'../../../../app/src/Features/Subscription/UserFeaturesUpdater'
|
|
|
|
const { assert } = require('chai')
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('UserFeaturesUpdater', function () {
|
|
|
|
beforeEach(function () {
|
2020-11-03 04:19:05 -05:00
|
|
|
this.User = { updateOne: sinon.stub().callsArgWith(2) }
|
2019-05-29 05:21:06 -04:00
|
|
|
return (this.UserFeaturesUpdater = SandboxedModule.require(modulePath, {
|
|
|
|
requires: {
|
|
|
|
'../../models/User': {
|
|
|
|
User: this.User
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}))
|
|
|
|
})
|
|
|
|
|
2021-04-14 09:17:21 -04:00
|
|
|
describe('updateFeatures', function () {
|
|
|
|
it('should send the users features', function (done) {
|
2019-05-29 05:21:06 -04:00
|
|
|
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
|
|
|
|
}
|
2020-11-03 04:19:05 -05:00
|
|
|
this.User.updateOne
|
2019-05-29 05:21:06 -04:00
|
|
|
.calledWith({ _id: user_id }, update)
|
|
|
|
.should.equal(true)
|
|
|
|
features.should.deep.equal(this.features)
|
|
|
|
return done()
|
|
|
|
}
|
|
|
|
)
|
2019-08-07 10:04:04 -04:00
|
|
|
})
|
|
|
|
})
|
2019-05-29 05:21:06 -04:00
|
|
|
})
|