-
Notifications
You must be signed in to change notification settings - Fork 58
/
Copy pathcreate-warning-connection.email.test.js
140 lines (121 loc) · 5.7 KB
/
create-warning-connection.email.test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
import { createWarningConnectionEmail } from '../../../../../src/identity-access-management/domain/emails/create-warning-connection.email.js';
import { Email } from '../../../../../src/shared/mail/domain/models/Email.js';
import { mailer } from '../../../../../src/shared/mail/infrastructure/services/mailer.js';
import { expect } from '../../../../test-helper.js';
describe('Unit | Identity Access Management | Domain | Email | create-warning-connection', function () {
it('creates warning connection email with the right parameters', function () {
const emailParams = {
email: 'test@example.com',
locale: 'fr',
firstName: 'John',
validationToken: 'token',
};
const email = createWarningConnectionEmail(emailParams);
expect(email).to.be.instanceof(Email);
expect(email).to.have.property('subject').that.is.a('string');
expect(email.to).to.equal(emailParams.email);
expect(email.template).to.equal(mailer.warningConnectionTemplateId);
const variables = email.variables;
expect(variables).to.have.property('homeName').that.is.a('string');
expect(variables).to.have.property('homeUrl').that.is.a('string');
expect(variables).to.have.property('displayNationalLogo').that.is.a('boolean');
expect(variables).to.have.property('contactUs').that.is.a('string');
expect(variables).to.have.property('doNotAnswer').that.is.a('string');
expect(variables).to.have.property('moreOn').that.is.a('string');
expect(variables).to.have.property('pixPresentation').that.is.a('string');
expect(variables).to.have.property('hello').that.is.a('string');
expect(variables).to.have.property('context').that.is.a('string');
expect(variables).to.have.property('disclaimer').that.is.a('string');
expect(variables).to.have.property('warningMessage').that.is.a('string');
expect(variables).to.have.property('resetMyPassword').that.is.a('string');
expect(variables).to.have.property('supportContact').that.is.a('string');
expect(variables).to.have.property('helpDeskUrl').that.is.a('string');
expect(variables).to.have.property('resetUrl').that.is.a('string');
expect(variables).to.have.property('thanks').that.is.a('string');
expect(variables).to.have.property('signing').that.is.a('string');
});
describe('when the locale is en', function () {
it('provides the correct urls', function () {
// given
const emailParams = {
email: 'toto@example.net',
locale: 'en',
firstName: 'John',
validationToken: 'token',
};
// when
const email = createWarningConnectionEmail(emailParams);
// then
const { helpDeskUrl, resetUrl } = email.variables;
const expectedSupportUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Fen%2Fsupport';
const expectedResetUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Den';
expect(resetUrl).to.equal(expectedResetUrl);
expect(helpDeskUrl).to.equal(expectedSupportUrl);
});
});
describe('when the locale is fr-fr', function () {
it('provides the correct urls', function () {
// given
const emailParams = {
email: 'toto@example.net',
locale: 'fr-fr',
firstName: 'John',
validationToken: 'token',
};
// when
const email = createWarningConnectionEmail(emailParams);
// then
const { helpDeskUrl, resetUrl } = email.variables;
const expectedSupportUrl =
'https://test.app.pix.fr/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.fr%2Fsupport';
const expectedResetUrl =
'https://test.app.pix.fr/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.fr%2Fmot-de-passe-oublie%3Flang%3Dfr';
expect(resetUrl).to.equal(expectedResetUrl);
expect(helpDeskUrl).to.equal(expectedSupportUrl);
});
});
describe('when the locale is fr', function () {
it('provides the correct urls', function () {
// given
const emailParams = {
email: 'toto@example.net',
locale: 'fr',
firstName: 'John',
validationToken: 'token',
};
// when
const email = createWarningConnectionEmail(emailParams);
// then
const { helpDeskUrl, resetUrl } = email.variables;
const expectedSupportUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Ffr%2Fsupport';
const expectedResetUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Dfr';
expect(resetUrl).to.equal(expectedResetUrl);
expect(helpDeskUrl).to.equal(expectedSupportUrl);
});
});
describe('when the locale is nl-BE', function () {
it('provides the correct urls', function () {
// given
const emailParams = {
email: 'toto@example.net',
locale: 'nl-BE',
firstName: 'John',
validationToken: 'token',
};
// when
const email = createWarningConnectionEmail(emailParams);
// then
const { resetUrl, helpDeskUrl } = email.variables;
const expectedResetUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Ftest.app.pix.org%2Fmot-de-passe-oublie%3Flang%3Dnl';
const expectedSupportUrl =
'https://test.app.pix.org/api/users/validate-email?token=token&redirect_url=https%3A%2F%2Fpix.org%2Fnl-be%2Fsupport';
expect(resetUrl).to.equal(expectedResetUrl);
expect(helpDeskUrl).to.equal(expectedSupportUrl);
});
});
});