Skip to content

Commit

Permalink
Fix jasmine 3.4 (parse-community#5573)
Browse files Browse the repository at this point in the history
* Fix failing tests

* just ignore the test for now.

* Bumping jasmine

* Fix pg unhandled exception

* Improving the way the test is fixed

* Fix unhandled failed promise in postgres test

* Solving unhandled promise fail on redis test

* Returning the excluded test

* Fixing package-lock

* Fix unhandled promise from redis test
  • Loading branch information
davimacedo authored and acinader committed May 9, 2019
1 parent 7284c9a commit fe150e5
Show file tree
Hide file tree
Showing 6 changed files with 67 additions and 39 deletions.
16 changes: 8 additions & 8 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@
"flow-bin": "0.98.1",
"gaze": "1.1.3",
"husky": "2.2.0",
"jasmine": "3.1.0",
"jasmine": "3.4.0",
"jasmine-spec-reporter": "4.2.1",
"jsdoc": "3.6.1",
"jsdoc-babel": "0.5.0",
Expand Down
27 changes: 18 additions & 9 deletions spec/ParseLiveQueryServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -158,11 +158,14 @@ describe('ParseLiveQueryServer', function() {
classNames: ['Yolo'],
},
startLiveQueryServer: true,
__indexBuildCompletionCallbackForTests: promise => {
promise.then(() => {
expect(parseServer.liveQueryServer).not.toBeUndefined();
expect(parseServer.liveQueryServer.server).toBe(parseServer.server);
parseServer.server.close(() => done());
});
},
});

expect(parseServer.liveQueryServer).not.toBeUndefined();
expect(parseServer.liveQueryServer.server).toBe(parseServer.server);
parseServer.server.close(() => done());
});

it('can be initialized through ParseServer with liveQueryServerOptions', function(done) {
Expand All @@ -178,12 +181,18 @@ describe('ParseLiveQueryServer', function() {
liveQueryServerOptions: {
port: 22347,
},
__indexBuildCompletionCallbackForTests: promise => {
promise.then(() => {
expect(parseServer.liveQueryServer).not.toBeUndefined();
expect(parseServer.liveQueryServer.server).not.toBe(
parseServer.server
);
parseServer.liveQueryServer.server.close(() => {
parseServer.server.close(() => done());
});
});
},
});

expect(parseServer.liveQueryServer).not.toBeUndefined();
expect(parseServer.liveQueryServer.server).not.toBe(parseServer.server);
parseServer.liveQueryServer.server.close();
parseServer.server.close(() => done());
});
});

Expand Down
23 changes: 13 additions & 10 deletions spec/ParseServer.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,17 +62,20 @@ describe('Server Url Checks', () => {
}
const newConfiguration = Object.assign({}, defaultConfiguration, {
databaseAdapter,
});
const parseServer = ParseServer.start(newConfiguration, () => {
parseServer.handleShutdown();
parseServer.server.close(err => {
if (err) {
done.fail('Close Server Error');
}
reconfigureServer({}).then(() => {
done();
__indexBuildCompletionCallbackForTests: promise => {
promise.then(() => {
parseServer.handleShutdown();
parseServer.server.close(err => {
if (err) {
done.fail('Close Server Error');
}
reconfigureServer({}).then(() => {
done();
});
});
});
});
},
});
const parseServer = ParseServer.start(newConfiguration);
});
});
32 changes: 23 additions & 9 deletions spec/Schema.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -440,13 +440,20 @@ describe('SchemaController', () => {
// If two callers race to create the same schema, the response to the
// race loser should be the same as if they hadn't been racing.
config.database.loadSchema().then(schema => {
const p1 = schema.addClassIfNotExists('NewClass', {
foo: { type: 'String' },
});
const p2 = schema.addClassIfNotExists('NewClass', {
foo: { type: 'String' },
});
Promise.race([p1, p2]).then(actualSchema => {
const p1 = schema
.addClassIfNotExists('NewClass', {
foo: { type: 'String' },
})
.then(validateSchema)
.catch(validateError);
const p2 = schema
.addClassIfNotExists('NewClass', {
foo: { type: 'String' },
})
.then(validateSchema)
.catch(validateError);
let schemaValidated = false;
function validateSchema(actualSchema) {
const expectedSchema = {
className: 'NewClass',
fields: {
Expand All @@ -467,10 +474,17 @@ describe('SchemaController', () => {
},
};
expect(dd(actualSchema, expectedSchema)).toEqual(undefined);
});
Promise.all([p1, p2]).catch(error => {
schemaValidated = true;
}
let errorValidated = false;
function validateError(error) {
expect(error.code).toEqual(Parse.Error.INVALID_CLASS_NAME);
expect(error.message).toEqual('Class NewClass already exists.');
errorValidated = true;
}
Promise.all([p1, p2]).then(() => {
expect(schemaValidated).toEqual(true);
expect(errorValidated).toEqual(true);
done();
});
});
Expand Down
6 changes: 4 additions & 2 deletions src/ParseServer.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,11 +97,13 @@ class ParseServer {

logging.setLogger(loggerController);
const dbInitPromise = databaseController.performInitialization();
hooksController.load();
const hooksLoadPromise = hooksController.load();

// Note: Tests will start to fail if any validation happens after this is called.
if (process.env.TESTING) {
__indexBuildCompletionCallbackForTests(dbInitPromise);
__indexBuildCompletionCallbackForTests(
Promise.all([dbInitPromise, hooksLoadPromise])
);
}

if (cloud) {
Expand Down

0 comments on commit fe150e5

Please sign in to comment.