Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

test: fix failing tests on 4.x LTS branch #7661

Merged
merged 7 commits into from
Oct 30, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions package-lock.json

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

1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@
"form-data": "3.0.0",
"husky": "4.2.5",
"jasmine": "3.5.0",
"jasmine-spec-reporter": "7.0.0",
"jsdoc": "3.6.7",
"jsdoc-babel": "0.5.0",
"lint-staged": "10.2.3",
Expand Down
4 changes: 2 additions & 2 deletions spec/ParseLiveQuery.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -949,7 +949,7 @@ describe('ParseLiveQuery', function () {
const response = (obj, prev) => {
expect(obj.get('sessionToken')).toBeUndefined();
expect(obj.sessionToken).toBeUndefined();
expect(prev?.sessionToken).toBeUndefined();
expect(prev && prev.sessionToken).toBeUndefined();
if (prev && prev.get) {
expect(prev.get('sessionToken')).toBeUndefined();
}
Expand All @@ -968,7 +968,7 @@ describe('ParseLiveQuery', function () {
user.set('yolo', 'bar');
await user.save();
await user.destroy();
await new Promise(resolve => process.nextTick(resolve));
await new Promise(resolve => setTimeout(resolve, 10));
for (const key of events) {
expect(calls[key]).toHaveBeenCalled();
}
Expand Down
9 changes: 6 additions & 3 deletions spec/ParseUser.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -3948,7 +3948,7 @@ describe('Parse.User testing', () => {
const response = (obj, prev) => {
expect(obj.get('authData')).toBeUndefined();
expect(obj.authData).toBeUndefined();
expect(prev?.authData).toBeUndefined();
expect(prev && prev.authData).toBeUndefined();
if (prev && prev.get) {
expect(prev.get('authData')).toBeUndefined();
}
Expand All @@ -3960,18 +3960,21 @@ describe('Parse.User testing', () => {
subscription.on(key, calls[key]);
}
const user = await Parse.User._logInWith('facebook');

user.set('foo', 'bar');
await user.save();
user.unset('foo');
await user.save();
user.set('yolo', 'bar');
await user.save();
await user.destroy();
await new Promise(resolve => process.nextTick(resolve));
await new Promise(resolve => setTimeout(resolve, 10));
for (const key of events) {
expect(calls[key]).toHaveBeenCalled();
}
subscription.unsubscribe();
const client = await Parse.CoreManager.getLiveQueryController().getDefaultLiveQueryClient();
client.close();
await new Promise(resolve => setTimeout(resolve, 10));
});

describe('issue #4897', () => {
Expand Down
5 changes: 5 additions & 0 deletions spec/helper.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,11 @@
'use strict';
const CurrentSpecReporter = require('./support/CurrentSpecReporter.js');
const { SpecReporter } = require('jasmine-spec-reporter');

// Sets up a Parse API server for testing.
jasmine.DEFAULT_TIMEOUT_INTERVAL = process.env.PARSE_SERVER_TEST_TIMEOUT || 5000;
jasmine.getEnv().addReporter(new CurrentSpecReporter());
jasmine.getEnv().addReporter(new SpecReporter());

global.on_db = (db, callback, elseCallback) => {
if (process.env.PARSE_SERVER_TEST_DB == db) {
Expand Down
15 changes: 15 additions & 0 deletions spec/support/CurrentSpecReporter.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
// Sets a global variable to the current test spec
// ex: global.currentSpec.description

global.currentSpec = null;

class CurrentSpecReporter {
specStarted(spec) {
global.currentSpec = spec;
}
specDone() {
global.currentSpec = null;
}
}

module.exports = CurrentSpecReporter;