|
|
@@ -88,6 +88,10 @@ describe('UserDeleter', function () {
|
|
|
deleteMany: sinon.stub().returns({ exec: sinon.stub().resolves() }),
|
|
|
}
|
|
|
|
|
|
+ this.Modules = {
|
|
|
+ promises: { hooks: { fire: sinon.stub().resolves() } },
|
|
|
+ }
|
|
|
+
|
|
|
this.UserDeleter = SandboxedModule.require(modulePath, {
|
|
|
requires: {
|
|
|
'../../models/User': { User },
|
|
|
@@ -103,6 +107,7 @@ describe('UserDeleter', function () {
|
|
|
'../../models/UserAuditLogEntry': {
|
|
|
UserAuditLogEntry: this.UserAuditLogEntry,
|
|
|
},
|
|
|
+ '../../infrastructure/Modules': this.Modules,
|
|
|
},
|
|
|
})
|
|
|
})
|
|
|
@@ -194,6 +199,14 @@ describe('UserDeleter', function () {
|
|
|
).to.have.been.calledWith(this.userId)
|
|
|
})
|
|
|
|
|
|
+ it('should fire the deleteUser hook for modules', async function () {
|
|
|
+ await this.UserDeleter.promises.deleteUser(this.userId)
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'deleteUser',
|
|
|
+ this.userId
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
it('should stop the user sessions', async function () {
|
|
|
await this.UserDeleter.promises.deleteUser(this.userId)
|
|
|
expect(
|
|
|
@@ -488,6 +501,14 @@ describe('UserDeleter', function () {
|
|
|
this.mockedDeletedUser.verify()
|
|
|
})
|
|
|
|
|
|
+ it('should fire the expireDeletedUser hook for modules', async function () {
|
|
|
+ await this.UserDeleter.promises.expireDeletedUser('giraffe')
|
|
|
+ expect(this.Modules.promises.hooks.fire).to.have.been.calledWith(
|
|
|
+ 'expireDeletedUser',
|
|
|
+ 'giraffe'
|
|
|
+ )
|
|
|
+ })
|
|
|
+
|
|
|
describe('when called as a callback', function () {
|
|
|
it('should expire the user', function (done) {
|
|
|
this.UserDeleter.expireDeletedUser('giraffe', err => {
|