Skip to content

Commit 42c1b6d

Browse files
committed
tests
1 parent 8814d4f commit 42c1b6d

File tree

1 file changed

+27
-47
lines changed

1 file changed

+27
-47
lines changed

spec/ValidationAndPasswordsReset.spec.js

Lines changed: 27 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -333,10 +333,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
333333
url: sendEmailOptions.link,
334334
followRedirects: false,
335335
});
336-
expect(response.status).toEqual(302);
337-
expect(response.text).toEqual(
338-
'Found. Redirecting to http://localhost:8378/1/apps/verify_email_success.html'
339-
);
336+
expect(response.status).toEqual(200);
337+
expect(response.text).toContain('Email verified!');
340338
user = await new Parse.Query(Parse.User).first({ useMasterKey: true });
341339
expect(user.get('emailVerified')).toEqual(true);
342340
user = await Parse.User.logIn('user', 'other-password');
@@ -674,10 +672,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
674672
url: sendEmailOptions.link,
675673
followRedirects: false,
676674
}).then(response => {
677-
expect(response.status).toEqual(302);
678-
expect(response.text).toEqual(
679-
'Found. Redirecting to http://localhost:8378/1/apps/verify_email_success.html'
680-
);
675+
expect(response.status).toEqual(200);
676+
expect(response.text).toContain('Email verified!');
681677
user
682678
.fetch()
683679
.then(
@@ -714,10 +710,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
714710
url: 'http://localhost:8378/1/apps/test/verify_email',
715711
followRedirects: false,
716712
}).then(response => {
717-
expect(response.status).toEqual(302);
718-
expect(response.text).toEqual(
719-
'Found. Redirecting to http://localhost:8378/1/apps/invalid_link.html'
720-
);
713+
expect(response.status).toEqual(200);
714+
expect(response.text).toContain('Invalid verification link!');
721715
done();
722716
});
723717
});
@@ -738,10 +732,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
738732
url: 'http://localhost:8378/1/apps/test/verify_email?token=asdfasdf',
739733
followRedirects: false,
740734
}).then(response => {
741-
expect(response.status).toEqual(302);
742-
expect(response.text).toEqual(
743-
'Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=asdfasdf'
744-
);
735+
expect(response.status).toEqual(200);
736+
expect(response.text).toContain('Invalid verification link!');
745737
done();
746738
});
747739
});
@@ -766,10 +758,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
766758
username: 'sadfasga',
767759
},
768760
}).then(response => {
769-
expect(response.status).toEqual(302);
770-
expect(response.text).toEqual(
771-
'Found. Redirecting to http://localhost:8378/1/apps/link_send_fail.html'
772-
);
761+
expect(response.status).toEqual(303);
762+
expect(response.text).toContain('email_verification_send_fail.html');
773763
done();
774764
});
775765
});
@@ -783,10 +773,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
783773
url: 'http://localhost:8378/1/apps/test/verify_email?token=invalid',
784774
followRedirects: false,
785775
}).then(response => {
786-
expect(response.status).toEqual(302);
787-
expect(response.text).toEqual(
788-
'Found. Redirecting to http://localhost:8378/1/apps/invalid_verification_link.html?appId=test&token=invalid'
789-
);
776+
expect(response.status).toEqual(200);
777+
expect(response.text).toContain('Invalid verification link!');
790778
user.fetch().then(() => {
791779
expect(user.get('emailVerified')).toEqual(false);
792780
done();
@@ -824,8 +812,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
824812
url: options.link,
825813
followRedirects: false,
826814
}).then(response => {
827-
expect(response.status).toEqual(302);
828-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=[a-zA-Z0-9]+\&id=test\&/;
815+
expect(response.status).toEqual(200);
816+
const re = /name="token"[^>]*value="([^"]+)"/;
829817
expect(response.text.match(re)).not.toBe(null);
830818
done();
831819
});
@@ -868,10 +856,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
868856
url: 'http://localhost:8378/1/apps/test/request_password_reset?token=asdfasdf',
869857
followRedirects: false,
870858
}).then(response => {
871-
expect(response.status).toEqual(302);
872-
expect(response.text).toEqual(
873-
'Found. Redirecting to http://localhost:8378/1/apps/invalid_link.html'
874-
);
859+
expect(response.status).toEqual(200);
860+
expect(response.text).toContain('Invalid password reset link!');
875861
done();
876862
});
877863
});
@@ -886,8 +872,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
886872
url: options.link,
887873
followRedirects: false,
888874
}).then(response => {
889-
expect(response.status).toEqual(302);
890-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
875+
expect(response.status).toEqual(200);
876+
const re = /name="token"[^>]*value="([^"]+)"/;
891877
const match = response.text.match(re);
892878
if (!match) {
893879
fail('should have a token');
@@ -905,10 +891,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
905891
},
906892
followRedirects: false,
907893
}).then(response => {
908-
expect(response.status).toEqual(302);
909-
expect(response.text).toEqual(
910-
'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'
911-
);
894+
expect(response.status).toEqual(200);
895+
expect(response.text).toContain('Success!');
912896

913897
Parse.User.logIn('zxcv', 'hello').then(
914898
function () {
@@ -963,8 +947,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
963947
url: options.link,
964948
followRedirects: false,
965949
}).then(response => {
966-
expect(response.status).toEqual(302);
967-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
950+
expect(response.status).toEqual(200);
951+
const re = /name="token"[^>]*value="([^"]+)"/;
968952
const match = response.text.match(re);
969953
if (!match) {
970954
fail('should have a token');
@@ -982,10 +966,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
982966
},
983967
followRedirects: false,
984968
}).then(response => {
985-
expect(response.status).toEqual(302);
986-
expect(response.text).toEqual(
987-
'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'
988-
);
969+
expect(response.status).toEqual(200);
970+
expect(response.text).toContain('Success!');
989971
done();
990972
});
991973
});
@@ -1022,8 +1004,8 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
10221004
url: options.link,
10231005
followRedirects: false,
10241006
});
1025-
expect(response.status).toEqual(302);
1026-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
1007+
expect(response.status).toEqual(200);
1008+
const re = /name="token"[^>]*value="([^"]+)"/;
10271009
const match = response.text.match(re);
10281010
if (!match) {
10291011
fail('should have a token');
@@ -1197,9 +1179,7 @@ describe('Custom Pages, Email Verification, Password Reset', () => {
11971179
new_password: 'newpassword',
11981180
},
11991181
});
1200-
expect(res.text).toEqual(
1201-
`Found. Redirecting to http://localhost:8378/1/apps/choose_password?id=test&error=The%20password%20reset%20link%20has%20expired&app=emailVerifyToken&token=${token}`
1202-
);
1182+
expect(res.text).toContain('The password reset link has expired');
12031183

12041184
await request({
12051185
url: `http://localhost:8378/1/requestPasswordReset`,

0 commit comments

Comments
 (0)