Skip to content

Commit 8e988ef

Browse files
committed
Makes sure all tests can run without crashing
1 parent 3a5da32 commit 8e988ef

15 files changed

+270
-117
lines changed

spec/EmailVerificationToken.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ const MockEmailAdapterWithOptions = require('./MockEmailAdapterWithOptions');
44
const request = require('request');
55
const MongoClient = require("mongodb").MongoClient;
66

7-
describe_only_db('mongodb')("Email Verification Token Expiration: ", () => {
7+
describe_only_db('mongo')("Email Verification Token Expiration: ", () => {
88

99
it('show the invalid link page, if the user clicks on the verify email link after the email verify token expires', done => {
1010
var user = new Parse.User();

spec/Parse.Push.spec.js

Lines changed: 18 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
let request = require('request');
44

5-
describe('Parse.Push', () => {
5+
describe_only_db('mongo')('Parse.Push', () => {
66
var setup = function() {
77
var pushAdapter = {
88
send: function(body, installations) {
@@ -50,7 +50,7 @@ describe('Parse.Push', () => {
5050
});
5151
}
5252

53-
it_exclude_dbs(['postgres'])('should properly send push', (done) => {
53+
it('should properly send push', (done) => {
5454
return setup().then(() => {
5555
return Parse.Push.send({
5656
where: {
@@ -64,13 +64,13 @@ describe('Parse.Push', () => {
6464
})
6565
.then(() => {
6666
done();
67-
}, (err) => {
67+
}).catch((err) => {
6868
jfail(err);
6969
done();
7070
});
7171
});
7272

73-
it_exclude_dbs(['postgres'])('should properly send push with lowercaseIncrement', (done) => {
73+
it('should properly send push with lowercaseIncrement', (done) => {
7474
return setup().then(() => {
7575
return Parse.Push.send({
7676
where: {
@@ -83,13 +83,13 @@ describe('Parse.Push', () => {
8383
}, {useMasterKey: true})
8484
}).then(() => {
8585
done();
86-
}, (err) => {
86+
}).catch((err) => {
8787
jfail(err);
8888
done();
8989
});
9090
});
9191

92-
it_exclude_dbs(['postgres'])('should not allow clients to query _PushStatus', done => {
92+
it('should not allow clients to query _PushStatus', done => {
9393
setup()
9494
.then(() => Parse.Push.send({
9595
where: {
@@ -111,10 +111,13 @@ describe('Parse.Push', () => {
111111
expect(body.error).toEqual('unauthorized');
112112
done();
113113
});
114+
}).catch((err) => {
115+
jfail(err);
116+
done();
114117
});
115118
});
116119

117-
it_exclude_dbs(['postgres'])('should allow master key to query _PushStatus', done => {
120+
it('should allow master key to query _PushStatus', done => {
118121
setup()
119122
.then(() => Parse.Push.send({
120123
where: {
@@ -139,10 +142,13 @@ describe('Parse.Push', () => {
139142
expect(body.results[0].payload).toEqual('{"badge":"increment","alert":"Hello world!"}');
140143
done();
141144
});
145+
}).catch((err) => {
146+
jfail(err);
147+
done();
142148
});
143149
});
144150

145-
it_exclude_dbs(['postgres'])('should throw error if missing push configuration', done => {
151+
it('should throw error if missing push configuration', done => {
146152
reconfigureServer({push: null})
147153
.then(() => {
148154
return Parse.Push.send({
@@ -160,5 +166,8 @@ describe('Parse.Push', () => {
160166
expect(err.code).toEqual(Parse.Error.PUSH_MISCONFIGURED);
161167
done();
162168
});
163-
});
169+
}).catch((err) => {
170+
jfail(err);
171+
done();
172+
});
164173
});

spec/ParseFile.spec.js

Lines changed: 40 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -53,9 +53,13 @@ describe('Parse.File testing', () => {
5353
expect(b.name).toMatch(/_file.html/);
5454
expect(b.url).toMatch(/^http:\/\/localhost:8378\/1\/files\/test\/.*file.html$/);
5555
request.get(b.url, (error, response, body) => {
56-
expect(response.headers['content-type']).toMatch('^text/html');
57-
expect(error).toBe(null);
58-
expect(body).toEqual('<html></html>\n');
56+
try {
57+
expect(response.headers['content-type']).toMatch('^text/html');
58+
expect(error).toBe(null);
59+
expect(body).toEqual('<html></html>\n');
60+
} catch(e) {
61+
jfail(e);
62+
}
5963
done();
6064
});
6165
});
@@ -120,7 +124,11 @@ describe('Parse.File testing', () => {
120124
url: b.url
121125
}, (error, response, body) => {
122126
expect(error).toBe(null);
123-
expect(response.statusCode).toEqual(404);
127+
try {
128+
expect(response.statusCode).toEqual(404);
129+
} catch(e) {
130+
jfail(e);
131+
}
124132
done();
125133
});
126134
});
@@ -207,7 +215,7 @@ describe('Parse.File testing', () => {
207215
notEqual(file.name(), "hello.txt");
208216
done();
209217
}
210-
}));
218+
}, done));
211219
});
212220

213221
it_exclude_dbs(['postgres'])("save file in object", done => {
@@ -232,9 +240,9 @@ describe('Parse.File testing', () => {
232240
}
233241
}));
234242
}
235-
}));
243+
}, done));
236244
}
237-
}));
245+
}, done));
238246
});
239247

240248
it_exclude_dbs(['postgres'])("save file in object with escaped characters in filename", done => {
@@ -260,9 +268,9 @@ describe('Parse.File testing', () => {
260268
}
261269
}));
262270
}
263-
}));
271+
}, done));
264272
}
265-
}));
273+
}, done));
266274
});
267275

268276
it_exclude_dbs(['postgres'])("autosave file in object", done => {
@@ -282,9 +290,9 @@ describe('Parse.File testing', () => {
282290
notEqual(file.name(), "hello.txt");
283291
done();
284292
}
285-
}));
293+
}, done));
286294
}
287-
}));
295+
}, done));
288296
});
289297

290298
it_exclude_dbs(['postgres'])("autosave file in object in object", done => {
@@ -311,9 +319,9 @@ describe('Parse.File testing', () => {
311319
notEqual(file.name(), "hello.txt");
312320
done();
313321
}
314-
}));
322+
}, done));
315323
}
316-
}));
324+
}, done));
317325
});
318326

319327
it_exclude_dbs(['postgres'])("saving an already saved file", done => {
@@ -332,9 +340,9 @@ describe('Parse.File testing', () => {
332340
equal(file.name(), previousName);
333341
done();
334342
}
335-
}));
343+
}, done));
336344
}
337-
}));
345+
}, done));
338346
});
339347

340348
it_exclude_dbs(['postgres'])("two saves at the same time", done => {
@@ -366,7 +374,7 @@ describe('Parse.File testing', () => {
366374
ok(object.toJSON().file.url);
367375
done();
368376
}
369-
}));
377+
}, done));
370378
});
371379

372380
it_exclude_dbs(['postgres'])("content-type used with no extension", done => {
@@ -384,6 +392,10 @@ describe('Parse.File testing', () => {
384392
var b = JSON.parse(body);
385393
expect(b.name).toMatch(/\.html$/);
386394
request.get(b.url, (error, response, body) => {
395+
if (!response) {
396+
fail('response should be set');
397+
return done();
398+
}
387399
expect(response.headers['content-type']).toMatch(/^text\/html/);
388400
done();
389401
});
@@ -488,6 +500,9 @@ describe('Parse.File testing', () => {
488500
expect(fileAgain.name()).toEqual('meep');
489501
expect(fileAgain.url()).toEqual('http://meep.meep');
490502
done();
503+
}).catch((e) => {
504+
jfail(e);
505+
done();
491506
});
492507
});
493508

@@ -508,6 +523,9 @@ describe('Parse.File testing', () => {
508523
'http://files.parsetfss.com/test/tfss-123.txt'
509524
);
510525
done();
526+
}).catch((e) => {
527+
jfail(e);
528+
done();
511529
});
512530
});
513531

@@ -528,6 +546,9 @@ describe('Parse.File testing', () => {
528546
'http://files.parse.com/test/d6e80979-a128-4c57-a167-302f874700dc-123.txt'
529547
);
530548
done();
549+
}).catch((e) => {
550+
jfail(e);
551+
done();
531552
});
532553
});
533554

@@ -545,6 +566,9 @@ describe('Parse.File testing', () => {
545566
let fileAgain = result.get('file');
546567
expect(fileAgain.url()).toMatch(/123.txt$/);
547568
done();
569+
}).catch((e) => {
570+
jfail(e);
571+
done();
548572
});
549573
});
550574
});

spec/ParseGeoPoint.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ describe('Parse.GeoPoint testing', () => {
8686
done();
8787
}, (err) => {
8888
fail("Couldn't query GeoPoint");
89-
fail(err)
89+
jfail(err)
9090
});
9191
});
9292

spec/ParseGlobalConfig.spec.js

Lines changed: 14 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ describe('a GlobalConfig', () => {
1212
{ fields: {} },
1313
{ objectId: 1 },
1414
{ params: { companies: ['US', 'DK'] } }
15-
).then(done);
15+
).then(done, done);
1616
});
1717

1818
it_exclude_dbs(['postgres'])('can be retrieved', (done) => {
@@ -24,8 +24,10 @@ describe('a GlobalConfig', () => {
2424
'X-Parse-Master-Key' : 'test'
2525
}
2626
}, (error, response, body) => {
27-
expect(response.statusCode).toEqual(200);
28-
expect(body.params.companies).toEqual(['US', 'DK']);
27+
try {
28+
expect(response.statusCode).toEqual(200);
29+
expect(body.params.companies).toEqual(['US', 'DK']);
30+
} catch(e) { jfail(e); }
2931
done();
3032
});
3133
});
@@ -66,10 +68,12 @@ describe('a GlobalConfig', () => {
6668
'X-Parse-Master-Key' : 'test'
6769
}
6870
}, (error, response, body) => {
69-
expect(response.statusCode).toEqual(200);
70-
expect(body.params.companies).toBeUndefined();
71-
expect(body.params.foo).toBe('bar');
72-
expect(Object.keys(body.params).length).toBe(1);
71+
try {
72+
expect(response.statusCode).toEqual(200);
73+
expect(body.params.companies).toBeUndefined();
74+
expect(body.params.foo).toBe('bar');
75+
expect(Object.keys(body.params).length).toBe(1);
76+
} catch(e) { jfail(e); }
7377
done();
7478
});
7579
});
@@ -110,6 +114,9 @@ describe('a GlobalConfig', () => {
110114
expect(body.params).toEqual({});
111115
done();
112116
});
117+
}).catch((e) => {
118+
jfail(e);
119+
done();
113120
});
114121
});
115122
});

0 commit comments

Comments
 (0)