Skip to content

Commit 8814d4f

Browse files
committed
tests
1 parent a09c99e commit 8814d4f

File tree

1 file changed

+19
-37
lines changed

1 file changed

+19
-37
lines changed

spec/EmailVerificationToken.spec.js

Lines changed: 19 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -40,12 +40,8 @@ describe('Email Verification Token Expiration:', () => {
4040
url: sendEmailOptions.link,
4141
followRedirects: false,
4242
});
43-
expect(response.status).toEqual(302);
44-
const url = new URL(sendEmailOptions.link);
45-
const token = url.searchParams.get('token');
46-
expect(response.text).toEqual(
47-
`Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=${token}`
48-
);
43+
expect(response.status).toEqual(200);
44+
expect(response.text).toContain('Invalid verification link!');
4945
});
5046

5147
it('emailVerified should set to false, if the user does not verify their email before the email verify token expires', async () => {
@@ -81,7 +77,7 @@ describe('Email Verification Token Expiration:', () => {
8177
url: sendEmailOptions.link,
8278
followRedirects: false,
8379
});
84-
expect(response.status).toEqual(302);
80+
expect(response.status).toEqual(200);
8581
await user.fetch();
8682
expect(user.get('emailVerified')).toEqual(false);
8783
});
@@ -114,10 +110,8 @@ describe('Email Verification Token Expiration:', () => {
114110
url: sendEmailOptions.link,
115111
followRedirects: false,
116112
});
117-
expect(response.status).toEqual(302);
118-
expect(response.text).toEqual(
119-
'Found. Redirecting to http://localhost:8378/1/apps/verify_email_success.html'
120-
);
113+
expect(response.status).toEqual(200);
114+
expect(response.text).toContain('Email verified!');
121115
});
122116

123117
it_id('94956799-c85e-4297-b879-e2d1f985394c')(it)('if user clicks on the email verify link before email verification token expiration then emailVerified should be true', async () => {
@@ -148,7 +142,7 @@ describe('Email Verification Token Expiration:', () => {
148142
url: sendEmailOptions.link,
149143
followRedirects: false,
150144
});
151-
expect(response.status).toEqual(302);
145+
expect(response.status).toEqual(200);
152146
await user.fetch();
153147
expect(user.get('emailVerified')).toEqual(true);
154148
});
@@ -181,7 +175,7 @@ describe('Email Verification Token Expiration:', () => {
181175
url: sendEmailOptions.link,
182176
followRedirects: false,
183177
});
184-
expect(response.status).toEqual(302);
178+
expect(response.status).toEqual(200);
185179
const verifiedUser = await Parse.User.logIn('testEmailVerifyTokenValidity', 'expiringToken');
186180
expect(typeof verifiedUser).toBe('object');
187181
expect(verifiedUser.get('emailVerified')).toBe(true);
@@ -268,9 +262,7 @@ describe('Email Verification Token Expiration:', () => {
268262
url: `http://localhost:8378/1/apps/test/verify_email?token=${token}`,
269263
method: 'GET',
270264
});
271-
expect(res.text).toEqual(
272-
`Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=${token}`
273-
);
265+
expect(res.text).toContain('Invalid verification link!');
274266

275267
const formUrl = `http://localhost:8378/1/apps/test/resend_verification_email`;
276268
const formResponse = await request({
@@ -282,9 +274,7 @@ describe('Email Verification Token Expiration:', () => {
282274
headers: { 'Content-Type': 'application/x-www-form-urlencoded' },
283275
followRedirects: false,
284276
});
285-
expect(formResponse.text).toEqual(
286-
`Found. Redirecting to http://localhost:8378/1/apps/link_send_success.html`
287-
);
277+
expect(formResponse.text).toContain('email_verification_send_success.html');
288278
});
289279

290280
it_id('9365c53c-b8b4-41f7-a3c1-77882f76a89c')(it)('can conditionally send emails', async () => {
@@ -493,7 +483,7 @@ describe('Email Verification Token Expiration:', () => {
493483
url: sendEmailOptions.link,
494484
followRedirects: false,
495485
});
496-
expect(response.status).toEqual(302);
486+
expect(response.status).toEqual(200);
497487
const config = Config.get('test');
498488
const results = await config.database.find('_User', {
499489
username: 'unsets_email_verify_token_expires_at',
@@ -536,7 +526,7 @@ describe('Email Verification Token Expiration:', () => {
536526
url: sendEmailOptions.link,
537527
followRedirects: false,
538528
});
539-
expect(response.status).toEqual(302);
529+
expect(response.status).toEqual(200);
540530
const config = Config.get('test');
541531
const results = await config.database.find('_User', {
542532
username: 'unsets_email_verify_token_expires_at',
@@ -580,7 +570,7 @@ describe('Email Verification Token Expiration:', () => {
580570
url: sendEmailOptions.link,
581571
followRedirects: false,
582572
});
583-
expect(response.status).toEqual(302);
573+
expect(response.status).toEqual(200);
584574
await user.fetch();
585575
expect(user.get('emailVerified')).toEqual(true);
586576
// RECONFIGURE the server i.e., ENABLE the expire email verify token flag
@@ -591,12 +581,8 @@ describe('Email Verification Token Expiration:', () => {
591581
url: sendEmailOptions.link,
592582
followRedirects: false,
593583
});
594-
expect(response.status).toEqual(302);
595-
const url = new URL(sendEmailOptions.link);
596-
const token = url.searchParams.get('token');
597-
expect(response.text).toEqual(
598-
`Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=${token}`
599-
);
584+
expect(response.status).toEqual(200);
585+
expect(response.text).toContain('Invalid verification link!');
600586
});
601587

602588
it('clicking on the email verify link by an email UNVERIFIED user that was setup before enabling the expire email verify token should show invalid verficiation link page', async () => {
@@ -637,12 +623,8 @@ describe('Email Verification Token Expiration:', () => {
637623
url: sendEmailOptions.link,
638624
followRedirects: false,
639625
});
640-
expect(response.status).toEqual(302);
641-
const url = new URL(sendEmailOptions.link);
642-
const token = url.searchParams.get('token');
643-
expect(response.text).toEqual(
644-
`Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=${token}`
645-
);
626+
expect(response.status).toEqual(200);
627+
expect(response.text).toContain('Invalid verification link!');
646628
});
647629

648630
it_id('b6c87f35-d887-477d-bc86-a9217a424f53')(it)('setting the email on the user should set a new email verification token and new expiration date for the token when expire email verify token flag is set', async () => {
@@ -958,7 +940,7 @@ describe('Email Verification Token Expiration:', () => {
958940
url: sendEmailOptions.link,
959941
followRedirects: false,
960942
});
961-
expect(response.status).toEqual(302);
943+
expect(response.status).toEqual(200);
962944
expect(sendVerificationEmailCallCount).toBe(1);
963945

964946
response = await request({
@@ -1143,7 +1125,7 @@ describe('Email Verification Token Expiration:', () => {
11431125
url: sendEmailOptions.link,
11441126
followRedirects: false,
11451127
});
1146-
expect(response.status).toEqual(302);
1128+
expect(response.status).toEqual(200);
11471129
user = await Parse.User.logIn('testEmailVerifyTokenValidity', 'expiringToken');
11481130
expect(typeof user).toBe('object');
11491131
expect(user.get('emailVerified')).toBe(true);
@@ -1159,6 +1141,6 @@ describe('Email Verification Token Expiration:', () => {
11591141
url: sendEmailOptions.link,
11601142
followRedirects: false,
11611143
});
1162-
expect(response.status).toEqual(302);
1144+
expect(response.status).toEqual(200);
11631145
});
11641146
});

0 commit comments

Comments
 (0)