Skip to content

Commit beb1da3

Browse files
author
Arthur Cinader
committed
Two tests that fail often. Give em a little more time.
1 parent d5940b1 commit beb1da3

File tree

3 files changed

+21
-17
lines changed

3 files changed

+21
-17
lines changed

spec/CloudCodeLogger.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,8 +156,9 @@ describe("Cloud Code Logger", () => {
156156
.save()
157157
.then(
158158
() => done.fail('this is not supposed to succeed'),
159-
() => logController.getLogs({ from: Date.now() - 500, size: 1000 })
159+
() => new Promise(resolve => setTimeout(resolve, 100))
160160
)
161+
.then(() => logController.getLogs({ from: Date.now() - 500, size: 1000 }))
161162
.then(logs => {
162163
const log = logs[1]; // 0 is the 'uh oh!' from rejection...
163164
expect(log.level).toEqual('error');

spec/ParseHooks.spec.js

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -421,8 +421,8 @@ describe('Hooks', () => {
421421
// But this should override the key upon return
422422
res.json({success: object});
423423
});
424-
// The function is delete as the DB is dropped between calls
425-
Parse.Hooks.createTrigger("SomeRandomObject", "beforeSave" ,hookServerURL + "/BeforeSaveSome").then(function(){
424+
// The function is deleted as the DB is dropped between calls
425+
Parse.Hooks.createTrigger("SomeRandomObject", "beforeSave", hookServerURL + "/BeforeSaveSome").then(function () {
426426
const obj = new Parse.Object("SomeRandomObject");
427427
return obj.save();
428428
}).then(function(res) {
@@ -444,7 +444,7 @@ describe('Hooks', () => {
444444
object.set('hello', "world");
445445
res.json({success: object});
446446
});
447-
Parse.Hooks.createTrigger("SomeRandomObject2", "beforeSave" ,hookServerURL + "/BeforeSaveSome2").then(function(){
447+
Parse.Hooks.createTrigger("SomeRandomObject2", "beforeSave", hookServerURL + "/BeforeSaveSome2").then(function(){
448448
const obj = new Parse.Object("SomeRandomObject2");
449449
return obj.save();
450450
}).then(function(res) {
@@ -470,20 +470,19 @@ describe('Hooks', () => {
470470
res.json({success: {}});
471471
})
472472
});
473-
// The function is delete as the DB is dropped between calls
474-
Parse.Hooks.createTrigger("SomeRandomObject", "afterSave" ,hookServerURL + "/AfterSaveSome").then(function(){
473+
// The function is deleted as the DB is dropped between calls
474+
Parse.Hooks.createTrigger("SomeRandomObject", "afterSave", hookServerURL + "/AfterSaveSome").then(function(){
475475
const obj = new Parse.Object("SomeRandomObject");
476476
return obj.save();
477477
}).then(function() {
478478
var promise = new Parse.Promise();
479-
// Wait a bit here as it's an after save
480-
setTimeout(function(){
479+
// Wait a bit here as it's an after save
480+
setTimeout(() => {
481481
expect(triggerCount).toBe(1);
482-
var q = new Parse.Query("AnotherObject");
483-
q.get(newObjectId).then(function(r){
484-
promise.resolve(r);
485-
});
486-
}, 300)
482+
new Parse.Query("AnotherObject")
483+
.get(newObjectId)
484+
.then((r) => promise.resolve(r));
485+
}, 500);
487486
return promise;
488487
}).then(function(res){
489488
expect(res.get("foo")).toEqual("bar");

spec/ParseInstallation.spec.js

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ let config;
1212
let database;
1313
const defaultColumns = require('../src/Controllers/SchemaController').defaultColumns;
1414

15+
const delay = function delay(delay) {
16+
return new Promise(resolve => setTimeout(resolve, delay));
17+
}
18+
1519
const installationSchema = { fields: Object.assign({}, defaultColumns._Default, defaultColumns._Installation) };
1620

1721
describe('Installations', () => {
@@ -542,12 +546,14 @@ describe('Installations', () => {
542546
};
543547
return rest.create(config, auth.nobody(config), '_Installation', input);
544548
})
549+
.then(() => delay(100))
545550
.then(() => database.adapter.find('_Installation', installationSchema, {installationId: installId1}, {}))
546551
.then((results) => {
547552
expect(results.length).toEqual(1);
548553
firstObject = results[0];
549-
return database.adapter.find('_Installation', installationSchema, {installationId: installId2}, {});
550554
})
555+
.then(() => delay(100))
556+
.then(() => database.adapter.find('_Installation', installationSchema, {installationId: installId2}, {}))
551557
.then(results => {
552558
expect(results.length).toEqual(1);
553559
secondObject = results[0];
@@ -558,14 +564,12 @@ describe('Installations', () => {
558564
};
559565
return rest.update(config, auth.nobody(config), '_Installation', secondObject.objectId, input);
560566
})
567+
.then(() => delay(100))
561568
.then(() => database.adapter.find('_Installation', installationSchema, {objectId: firstObject.objectId}, {}))
562569
.then(results => {
563570
// The first object should have been deleted
564571
expect(results.length).toEqual(0);
565572
done();
566-
}).catch(error => {
567-
jfail(error);
568-
done();
569573
});
570574
});
571575

0 commit comments

Comments
 (0)