-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): Add a button to send a new certification center invitation
- Loading branch information
1 parent
60ac86b
commit fa4d53f
Showing
4 changed files
with
82 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -85,5 +85,58 @@ module('Unit | Controller | authenticated/certification-centers/get/invitations' | |
sinon.assert.calledWith(notificationErrorStub, { message: 'Une erreur s’est produite, veuillez réessayer.' }); | ||
assert.ok(true); | ||
}); | ||
|
||
module('#sendNewInvitation', function () { | ||
test('It sends a new invitation', async function (assert) { | ||
// given | ||
const controller = this.owner.lookup('controller:authenticated/certification-centers/get/invitations'); | ||
|
||
const store = this.owner.lookup('service:store'); | ||
const queryRecordStub = sinon.stub(); | ||
store.queryRecord = queryRecordStub; | ||
const certificationCenterInvitation = { | ||
email: '[email protected]', | ||
language: 'en', | ||
role: 'member', | ||
certificationCenterId: 1, | ||
}; | ||
// when | ||
await controller.sendNewCertificationCenterInvitation(certificationCenterInvitation); | ||
|
||
// then | ||
assert.ok( | ||
queryRecordStub.calledWith('certification-center-invitation', { | ||
...certificationCenterInvitation, | ||
}), | ||
); | ||
}); | ||
|
||
test('When an error occurs, it should send a notification error', async function (assert) { | ||
// given | ||
const controller = this.owner.lookup('controller:authenticated/certification-centers/get/invitations'); | ||
const store = this.owner.lookup('service:store'); | ||
const anError = Symbol('an error'); | ||
store.queryRecord = sinon.stub().rejects(anError); | ||
const notifyStub = sinon.stub(); | ||
class ErrorResponseHandler extends Service { | ||
notify = notifyStub; | ||
} | ||
this.owner.register('service:error-response-handler', ErrorResponseHandler); | ||
const customErrors = Symbol('custom errors'); | ||
controller.CUSTOM_ERROR_MESSAGES = customErrors; | ||
const certificationCenterInvitation = { | ||
email: '[email protected]', | ||
language: 'en', | ||
role: 'member', | ||
certificationCenterId: 1, | ||
}; | ||
|
||
// when | ||
await controller.sendNewCertificationCenterInvitation(certificationCenterInvitation); | ||
|
||
// then | ||
assert.ok(notifyStub.calledWithExactly(anError, customErrors)); | ||
}); | ||
}); | ||
}); | ||
}); |