| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667 |
- /* eslint-disable
- n/handle-callback-err,
- max-len,
- no-return-assign,
- */
- // 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 sinon = require('sinon')
- const assertCalledWith = sinon.assert.calledWith
- const { ObjectId } = require('mongodb')
- const modulePath =
- '../../../../app/src/Features/UserMembership/UserMembershipsHandler'
- const SandboxedModule = require('sandboxed-module')
- describe('UserMembershipsHandler', function () {
- beforeEach(function () {
- this.user = { _id: new ObjectId() }
- this.Institution = { updateMany: sinon.stub().yields(null) }
- this.Subscription = { updateMany: sinon.stub().yields(null) }
- this.Publisher = { updateMany: sinon.stub().yields(null) }
- return (this.UserMembershipsHandler = SandboxedModule.require(modulePath, {
- requires: {
- '../../models/Institution': {
- Institution: this.Institution,
- },
- '../../models/Subscription': {
- Subscription: this.Subscription,
- },
- '../../models/Publisher': {
- Publisher: this.Publisher,
- },
- },
- }))
- })
- describe('remove user', function () {
- it('remove user from all entities', function (done) {
- return this.UserMembershipsHandler.removeUserFromAllEntities(
- this.user._id,
- error => {
- assertCalledWith(
- this.Institution.updateMany,
- {},
- { $pull: { managerIds: this.user._id } }
- )
- assertCalledWith(
- this.Subscription.updateMany,
- {},
- { $pull: { manager_ids: this.user._id } }
- )
- assertCalledWith(
- this.Publisher.updateMany,
- {},
- { $pull: { managerIds: this.user._id } }
- )
- return done()
- }
- )
- })
- })
- })
|