Skip to content

Commit b13b1ba

Browse files
committed
Alls tests should pass
1 parent b5c4ed1 commit b13b1ba

File tree

6 files changed

+18
-61
lines changed

6 files changed

+18
-61
lines changed

spec/.eslintrc.json

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,7 @@
2020
"describe_only": true,
2121
"on_db": true,
2222
"defaultConfiguration": true,
23-
"expectSuccess": true,
2423
"range": true,
25-
"expectError": true,
2624
"jequal": true,
2725
"create": true,
2826
"arrayContains": true

spec/FilesController.spec.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ describe("FilesController", () => {
4848
() => done.fail('should not succeed'),
4949
() => setImmediate(() => Promise.resolve('done'))
5050
)
51-
.then(() => logController.getLogs({ from: Date.now() - 500, size: 1000 }))
51+
.then(() => new Promise(resolve => setTimeout(resolve, 200)))
52+
.then(() => logController.getLogs({ from: Date.now() - 1000, size: 1000 }))
5253
.then((logs) => {
5354
// we get two logs here: 1. the source of the failure to save the file
5455
// and 2 the message that will be sent back to the client.

spec/ParseAPI.spec.js

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ describe('miscellaneous', function() {
6262
});
6363

6464
it('create a valid parse user', function(done) {
65-
createTestUser(function(data) {
65+
createTestUser().then(function(data) {
6666
expect(data.id).not.toBeUndefined();
6767
expect(data.getSessionToken()).not.toBeUndefined();
6868
expect(data.get('password')).toBeUndefined();
@@ -104,7 +104,8 @@ describe('miscellaneous', function() {
104104
.catch(done);
105105
});
106106

107-
it('ensure that email is uniquely indexed', done => {
107+
it('ensure that email is uniquely indexed', async done => {
108+
Parse.User.disableUnsafeCurrentUser();
108109
let numFailed = 0;
109110
let numCreated = 0;
110111
const user1 = new Parse.User();
@@ -138,9 +139,11 @@ describe('miscellaneous', function() {
138139
Promise.all([p1, p2])
139140
.then(() => {
140141
fail('one of the users should not have been created');
141-
done();
142142
})
143-
.catch(done);
143+
.finally(() => {
144+
Parse.User.enableUnsafeCurrentUser();
145+
done();
146+
});
144147
});
145148

146149
it('ensure that if people already have duplicate users, they can still sign up new users', done => {
@@ -229,15 +232,16 @@ describe('miscellaneous', function() {
229232
});
230233
});
231234

232-
it('succeed in logging in', function() {
233-
createTestUser(async function(u) {
235+
it('succeed in logging in', function(done) {
236+
createTestUser().then(async function(u) {
234237
expect(typeof u.id).toEqual('string');
235238

236239
const user = await Parse.User.logIn('test', 'moon-y');
237240
expect(typeof user.id).toEqual('string');
238241
expect(user.get('password')).toBeUndefined();
239242
expect(user.getSessionToken()).not.toBeUndefined();
240-
Parse.User.logOut();
243+
await Parse.User.logOut();
244+
done();
241245
}, fail);
242246
});
243247

spec/WinstonLoggerAdapter.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ describe('info logs', () => {
2121
// Check the error log
2222
// Regression #2639
2323
winstonLoggerAdapter.query({
24-
from: new Date(Date.now() - 500),
24+
from: new Date(Date.now() - 200),
2525
size: 100,
2626
level: 'error'
2727
}, (results) => {

spec/helper.js

Lines changed: 3 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -235,27 +235,14 @@ const Container = Parse.Object.extend({
235235
// Convenience method to create a new TestObject with a callback
236236
function create(options, callback) {
237237
const t = new TestObject(options);
238-
t.save().then(callback);
238+
return t.save().then(callback);
239239
}
240240

241-
function createTestUser(success, error) {
241+
function createTestUser() {
242242
const user = new Parse.User();
243243
user.set('username', 'test');
244244
user.set('password', 'moon-y');
245-
const promise = user.signUp();
246-
if (success || error) {
247-
promise.then(function(user) {
248-
if (success) {
249-
success(user);
250-
}
251-
}, function(err) {
252-
if (error) {
253-
error(err);
254-
}
255-
});
256-
} else {
257-
return promise;
258-
}
245+
return user.signUp();
259246
}
260247

261248
// Shims for compatibility with the old qunit tests.
@@ -271,37 +258,6 @@ function strictEqual(a, b, message) {
271258
function notEqual(a, b, message) {
272259
expect(a).not.toEqual(b, message);
273260
}
274-
function expectSuccess(params, done) {
275-
return {
276-
success: params.success,
277-
error: function() {
278-
fail('failure happened in expectSuccess');
279-
done ? done() : null;
280-
},
281-
}
282-
}
283-
function expectError(errorCode, callback) {
284-
return {
285-
success: function(result) {
286-
console.log('got result', result);
287-
fail('expected error but got success');
288-
},
289-
error: function(obj, e) {
290-
// Some methods provide 2 parameters.
291-
e = e || obj;
292-
if (errorCode !== undefined) {
293-
if (!e) {
294-
fail('expected a specific error but got a blank error');
295-
return;
296-
}
297-
expect(e.code).toEqual(errorCode, e.message);
298-
}
299-
if (callback) {
300-
callback(e);
301-
}
302-
},
303-
}
304-
}
305261

306262
// Because node doesn't have Parse._.contains
307263
function arrayContains(arr, item) {
@@ -393,8 +349,6 @@ global.ok = ok;
393349
global.equal = equal;
394350
global.strictEqual = strictEqual;
395351
global.notEqual = notEqual;
396-
global.expectSuccess = expectSuccess;
397-
global.expectError = expectError;
398352
global.arrayContains = arrayContains;
399353
global.jequal = jequal;
400354
global.range = range;

src/LiveQuery/ParseLiveQueryServer.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,7 +197,7 @@ class ParseLiveQueryServer {
197197
originalACLCheckingPromise,
198198
currentACLCheckingPromise
199199
]
200-
).then((isOriginalMatched, isCurrentMatched) => {
200+
).then(([isOriginalMatched, isCurrentMatched]) => {
201201
logger.verbose('Original %j | Current %j | Match: %s, %s, %s, %s | Query: %s',
202202
originalParseObject,
203203
currentParseObject,

0 commit comments

Comments
 (0)