Skip to content

Commit ef1c8c9

Browse files
committed
tests
1 parent a37e2e8 commit ef1c8c9

File tree

1 file changed

+30
-45
lines changed

1 file changed

+30
-45
lines changed

spec/PasswordPolicy.spec.js

Lines changed: 30 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,8 @@ describe('Password Policy: ', () => {
4646
resolveWithFullResponse: true,
4747
})
4848
.then(response => {
49-
expect(response.status).toEqual(302);
50-
expect(response.text).toEqual(
51-
'Found. Redirecting to http://localhost:8378/1/apps/invalid_link.html'
52-
);
49+
expect(response.status).toEqual(200);
50+
expect(response.text).toContain('Invalid password reset link!');
5351
done();
5452
})
5553
.catch(error => {
@@ -106,9 +104,8 @@ describe('Password Policy: ', () => {
106104
followRedirects: false,
107105
})
108106
.then(response => {
109-
expect(response.status).toEqual(302);
110-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=[a-zA-Z0-9]+\&id=test\&/;
111-
expect(response.text.match(re)).not.toBe(null);
107+
expect(response.status).toEqual(200);
108+
expect(response.text).toContain('password');
112109
done();
113110
})
114111
.catch(error => {
@@ -621,8 +618,8 @@ describe('Password Policy: ', () => {
621618
resolveWithFullResponse: true,
622619
})
623620
.then(response => {
624-
expect(response.status).toEqual(302);
625-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
621+
expect(response.status).toEqual(200);
622+
const re = /name="token"[^>]*value="([^"]+)"/;
626623
const match = response.text.match(re);
627624
if (!match) {
628625
fail('should have a token');
@@ -643,10 +640,8 @@ describe('Password Policy: ', () => {
643640
resolveWithFullResponse: true,
644641
})
645642
.then(response => {
646-
expect(response.status).toEqual(302);
647-
expect(response.text).toEqual(
648-
'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'
649-
);
643+
expect(response.status).toEqual(200);
644+
expect(response.text).toContain('Success!');
650645

651646
Parse.User.logIn('user1', 'has2init')
652647
.then(function () {
@@ -713,8 +708,8 @@ describe('Password Policy: ', () => {
713708
resolveWithFullResponse: true,
714709
})
715710
.then(response => {
716-
expect(response.status).toEqual(302);
717-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
711+
expect(response.status).toEqual(200);
712+
const re = /name="token"[^>]*value="([^"]+)"/;
718713
const match = response.text.match(re);
719714
if (!match) {
720715
fail('should have a token');
@@ -735,10 +730,8 @@ describe('Password Policy: ', () => {
735730
resolveWithFullResponse: true,
736731
})
737732
.then(response => {
738-
expect(response.status).toEqual(302);
739-
expect(response.text).toEqual(
740-
`Found. Redirecting to http://localhost:8378/1/apps/choose_password?token=${token}&id=test&error=Password%20should%20contain%20at%20least%20one%20digit.&app=passwordPolicy`
741-
);
733+
expect(response.status).toEqual(200);
734+
expect(response.text).toContain('Password should contain at least one digit.');
742735

743736
Parse.User.logIn('user1', 'has 1 digit')
744737
.then(function () {
@@ -899,8 +892,8 @@ describe('Password Policy: ', () => {
899892
resolveWithFullResponse: true,
900893
})
901894
.then(response => {
902-
expect(response.status).toEqual(302);
903-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
895+
expect(response.status).toEqual(200);
896+
const re = /name="token"[^>]*value="([^"]+)"/;
904897
const match = response.text.match(re);
905898
if (!match) {
906899
fail('should have a token');
@@ -921,10 +914,8 @@ describe('Password Policy: ', () => {
921914
resolveWithFullResponse: true,
922915
})
923916
.then(response => {
924-
expect(response.status).toEqual(302);
925-
expect(response.text).toEqual(
926-
`Found. Redirecting to http://localhost:8378/1/apps/choose_password?token=${token}&id=test&error=Password%20cannot%20contain%20your%20username.&app=passwordPolicy`
927-
);
917+
expect(response.status).toEqual(200);
918+
expect(response.text).toContain('Password cannot contain your username.');
928919

929920
Parse.User.logIn('user1', 'r@nd0m')
930921
.then(function () {
@@ -990,8 +981,8 @@ describe('Password Policy: ', () => {
990981
simple: false,
991982
resolveWithFullResponse: true,
992983
});
993-
expect(response.status).toEqual(302);
994-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
984+
expect(response.status).toEqual(200);
985+
const re = /name="token"[^>]*value="([^"]+)"/;
995986
const match = response.text.match(re);
996987
if (!match) {
997988
fail('should have a token');
@@ -1050,8 +1041,8 @@ describe('Password Policy: ', () => {
10501041
resolveWithFullResponse: true,
10511042
})
10521043
.then(response => {
1053-
expect(response.status).toEqual(302);
1054-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
1044+
expect(response.status).toEqual(200);
1045+
const re = /name="token"[^>]*value="([^"]+)"/;
10551046
const match = response.text.match(re);
10561047
if (!match) {
10571048
fail('should have a token');
@@ -1072,10 +1063,8 @@ describe('Password Policy: ', () => {
10721063
resolveWithFullResponse: true,
10731064
})
10741065
.then(response => {
1075-
expect(response.status).toEqual(302);
1076-
expect(response.text).toEqual(
1077-
'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'
1078-
);
1066+
expect(response.status).toEqual(200);
1067+
expect(response.text).toContain('Success!');
10791068

10801069
Parse.User.logIn('user1', 'uuser11')
10811070
.then(function () {
@@ -1316,8 +1305,8 @@ describe('Password Policy: ', () => {
13161305
resolveWithFullResponse: true,
13171306
})
13181307
.then(response => {
1319-
expect(response.status).toEqual(302);
1320-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
1308+
expect(response.status).toEqual(200);
1309+
const re = /name="token"[^>]*value="([^"]+)"/;
13211310
const match = response.text.match(re);
13221311
if (!match) {
13231312
fail('should have a token');
@@ -1338,10 +1327,8 @@ describe('Password Policy: ', () => {
13381327
resolveWithFullResponse: true,
13391328
})
13401329
.then(response => {
1341-
expect(response.status).toEqual(302);
1342-
expect(response.text).toEqual(
1343-
'Found. Redirecting to http://localhost:8378/1/apps/password_reset_success.html'
1344-
);
1330+
expect(response.status).toEqual(200);
1331+
expect(response.text).toContain('Success!');
13451332

13461333
Parse.User.logIn('user1', 'uuser11')
13471334
.then(function () {
@@ -1471,8 +1458,8 @@ describe('Password Policy: ', () => {
14711458
followRedirects: false,
14721459
})
14731460
.then(response => {
1474-
expect(response.status).toEqual(302);
1475-
const re = /http:\/\/localhost:8378\/1\/apps\/choose_password\?token=([a-zA-Z0-9]+)\&id=test\&/;
1461+
expect(response.status).toEqual(200);
1462+
const re = /name="token"[^>]*value="([^"]+)"/;
14761463
const match = response.text.match(re);
14771464
if (!match) {
14781465
fail('should have a token');
@@ -1498,10 +1485,8 @@ describe('Password Policy: ', () => {
14981485
.then(data => {
14991486
const response = data[0];
15001487
const token = data[1];
1501-
expect(response.status).toEqual(302);
1502-
expect(response.text).toEqual(
1503-
`Found. Redirecting to http://localhost:8378/1/apps/choose_password?token=${token}&id=test&error=New%20password%20should%20not%20be%20the%20same%20as%20last%201%20passwords.&app=passwordPolicy`
1504-
);
1488+
expect(response.status).toEqual(200);
1489+
expect(response.text).toContain('New password should not be the same as last 1 passwords.');
15051490
done();
15061491
return Promise.resolve();
15071492
})

0 commit comments

Comments
 (0)