Move admin register to user activate module

Move admin register to user activate module

Co-authored-by: John Lees-Miller <jdleesmiller@gmail.com> & Davinder Singh
GitOrigin-RevId: 79428f2932783086435bdad9b1efb5300c467511
This commit is contained in:
Davinder Singh
2022-04-07 14:41:05 +01:00
committed by Copybot
parent bce02b25e4
commit b3d55fa65e
8 changed files with 77 additions and 70 deletions
@@ -17,21 +17,27 @@ describe('UserActivateController', function () {
}
this.UserGetter = { getUser: sinon.stub() }
this.UserRegistrationHandler = {}
this.ErrorController = { notFound: sinon.stub() }
this.UserActivateController = SandboxedModule.require(MODULE_PATH, {
requires: {
'../../../../app/src/Features/User/UserGetter': this.UserGetter,
'../../../../app/src/Features/User/UserRegistrationHandler':
this.UserRegistrationHandler,
'../../../../app/src/Features/Errors/ErrorController':
this.ErrorController,
},
})
this.req = {
body: {},
query: {},
session: {
user: this.user,
},
}
this.res = {}
this.res = {
json: sinon.stub(),
}
})
describe('activateAccountPage', function () {
@@ -86,4 +92,30 @@ describe('UserActivateController', function () {
this.UserActivateController.activateAccountPage(this.req, this.res)
})
})
describe('register', function () {
beforeEach(function () {
this.UserRegistrationHandler.registerNewUserAndSendActivationEmail = sinon
.stub()
.callsArgWith(1, null, this.user, (this.url = 'mock/url'))
this.req.body.email = this.user.email = this.email = 'email@example.com'
this.UserActivateController.register(this.req, this.res)
})
it('should register the user and send them an email', function () {
sinon.assert.calledWith(
this.UserRegistrationHandler.registerNewUserAndSendActivationEmail,
this.email
)
})
it('should return the user and activation url', function () {
this.res.json
.calledWith({
email: this.email,
setNewPasswordUrl: this.url,
})
.should.equal(true)
})
})
})