@@ -119,7 +119,7 @@ const openConnections = {};
119
119
let server ;
120
120
121
121
// Allows testing specific configurations of Parse Server
122
- const reconfigureServer = changedConfiguration => {
122
+ const reconfigureServer = ( changedConfiguration ) => {
123
123
return new Promise ( ( resolve , reject ) => {
124
124
if ( server ) {
125
125
return server . close ( ( ) => {
@@ -134,7 +134,7 @@ const reconfigureServer = changedConfiguration => {
134
134
defaultConfiguration ,
135
135
changedConfiguration ,
136
136
{
137
- serverStartComplete : error => {
137
+ serverStartComplete : ( error ) => {
138
138
if ( error ) {
139
139
reject ( error ) ;
140
140
} else {
@@ -148,12 +148,12 @@ const reconfigureServer = changedConfiguration => {
148
148
cache . clear ( ) ;
149
149
parseServer = ParseServer . start ( newConfiguration ) ;
150
150
parseServer . app . use ( require ( './testing-routes' ) . router ) ;
151
- parseServer . expressApp . use ( '/1' , err => {
151
+ parseServer . expressApp . use ( '/1' , ( err ) => {
152
152
console . error ( err ) ;
153
153
fail ( 'should not call next' ) ;
154
154
} ) ;
155
155
server = parseServer . server ;
156
- server . on ( 'connection' , connection => {
156
+ server . on ( 'connection' , ( connection ) => {
157
157
const key = `${ connection . remoteAddress } :${ connection . remotePort } ` ;
158
158
openConnections [ key ] = connection ;
159
159
connection . on ( 'close' , ( ) => {
@@ -170,7 +170,7 @@ const reconfigureServer = changedConfiguration => {
170
170
const Parse = require ( 'parse/node' ) ;
171
171
Parse . serverURL = 'http://localhost:' + port + '/1' ;
172
172
173
- beforeEach ( done => {
173
+ beforeEach ( ( done ) => {
174
174
try {
175
175
Parse . User . enableUnsafeCurrentUser ( ) ;
176
176
} catch ( error ) {
@@ -179,7 +179,7 @@ beforeEach(done => {
179
179
}
180
180
}
181
181
TestUtils . destroyAllDataPermanently ( true )
182
- . catch ( error => {
182
+ . catch ( ( error ) => {
183
183
// For tests that connect to their own mongo, there won't be any data to delete.
184
184
if (
185
185
error . message === 'ns not found' ||
@@ -192,15 +192,16 @@ beforeEach(done => {
192
192
}
193
193
} )
194
194
. then ( reconfigureServer )
195
- . then ( ( ) => {
195
+ . then ( ( parseServer ) => {
196
+ global . parseServerFromBeforeEach = parseServer ;
196
197
Parse . initialize ( 'test' , 'test' , 'test' ) ;
197
198
Parse . serverURL = 'http://localhost:' + port + '/1' ;
198
199
done ( ) ;
199
200
} )
200
201
. catch ( done . fail ) ;
201
202
} ) ;
202
203
203
- afterEach ( function ( done ) {
204
+ afterEach ( function ( done ) {
204
205
const afterLogOut = ( ) => {
205
206
if ( Object . keys ( openConnections ) . length > 0 ) {
206
207
fail (
@@ -212,11 +213,11 @@ afterEach(function(done) {
212
213
Parse . Cloud . _removeAllHooks ( ) ;
213
214
databaseAdapter
214
215
. getAllClasses ( )
215
- . then ( allSchemas => {
216
- allSchemas . forEach ( schema => {
216
+ . then ( ( allSchemas ) => {
217
+ allSchemas . forEach ( ( schema ) => {
217
218
const className = schema . className ;
218
219
expect ( className ) . toEqual ( {
219
- asymmetricMatch : className => {
220
+ asymmetricMatch : ( className ) => {
220
221
if ( ! className . startsWith ( '_' ) ) {
221
222
return true ;
222
223
} else {
@@ -244,7 +245,7 @@ afterEach(function(done) {
244
245
) // swallow errors
245
246
. then ( ( ) => {
246
247
// Connection close events are not immediate on node 10+... wait a bit
247
- return new Promise ( resolve => {
248
+ return new Promise ( ( resolve ) => {
248
249
setTimeout ( resolve , 0 ) ;
249
250
} ) ;
250
251
} )
@@ -326,13 +327,13 @@ function range(n) {
326
327
327
328
function mockCustomAuthenticator ( id , password ) {
328
329
const custom = { } ;
329
- custom . validateAuthData = function ( authData ) {
330
+ custom . validateAuthData = function ( authData ) {
330
331
if ( authData . id === id && authData . password . startsWith ( password ) ) {
331
332
return Promise . resolve ( ) ;
332
333
}
333
334
throw new Parse . Error ( Parse . Error . OBJECT_NOT_FOUND , 'not validated' ) ;
334
335
} ;
335
- custom . validateAppId = function ( ) {
336
+ custom . validateAppId = function ( ) {
336
337
return Promise . resolve ( ) ;
337
338
} ;
338
339
return custom ;
@@ -344,14 +345,14 @@ function mockCustom() {
344
345
345
346
function mockFacebookAuthenticator ( id , token ) {
346
347
const facebook = { } ;
347
- facebook . validateAuthData = function ( authData ) {
348
+ facebook . validateAuthData = function ( authData ) {
348
349
if ( authData . id === id && authData . access_token . startsWith ( token ) ) {
349
350
return Promise . resolve ( ) ;
350
351
} else {
351
352
throw undefined ;
352
353
}
353
354
} ;
354
- facebook . validateAppId = function ( appId , authData ) {
355
+ facebook . validateAppId = function ( appId , authData ) {
355
356
if ( authData . access_token . startsWith ( token ) ) {
356
357
return Promise . resolve ( ) ;
357
358
} else {
@@ -368,17 +369,17 @@ function mockFacebook() {
368
369
function mockShortLivedAuth ( ) {
369
370
const auth = { } ;
370
371
let accessToken ;
371
- auth . setValidAccessToken = function ( validAccessToken ) {
372
+ auth . setValidAccessToken = function ( validAccessToken ) {
372
373
accessToken = validAccessToken ;
373
374
} ;
374
- auth . validateAuthData = function ( authData ) {
375
+ auth . validateAuthData = function ( authData ) {
375
376
if ( authData . access_token == accessToken ) {
376
377
return Promise . resolve ( ) ;
377
378
} else {
378
379
return Promise . reject ( 'Invalid access token' ) ;
379
380
}
380
381
} ;
381
- auth . validateAppId = function ( ) {
382
+ auth . validateAppId = function ( ) {
382
383
return Promise . resolve ( ) ;
383
384
} ;
384
385
return auth ;
@@ -403,19 +404,19 @@ global.defaultConfiguration = defaultConfiguration;
403
404
global . mockCustomAuthenticator = mockCustomAuthenticator ;
404
405
global . mockFacebookAuthenticator = mockFacebookAuthenticator ;
405
406
global . databaseAdapter = databaseAdapter ;
406
- global . jfail = function ( err ) {
407
+ global . jfail = function ( err ) {
407
408
fail ( JSON . stringify ( err ) ) ;
408
409
} ;
409
410
410
- global . it_exclude_dbs = excluded => {
411
+ global . it_exclude_dbs = ( excluded ) => {
411
412
if ( excluded . indexOf ( process . env . PARSE_SERVER_TEST_DB ) >= 0 ) {
412
413
return xit ;
413
414
} else {
414
415
return it ;
415
416
}
416
417
} ;
417
418
418
- global . it_only_db = db => {
419
+ global . it_only_db = ( db ) => {
419
420
if (
420
421
process . env . PARSE_SERVER_TEST_DB === db ||
421
422
( ! process . env . PARSE_SERVER_TEST_DB && db == 'mongo' )
@@ -426,15 +427,15 @@ global.it_only_db = db => {
426
427
}
427
428
} ;
428
429
429
- global . fit_exclude_dbs = excluded => {
430
+ global . fit_exclude_dbs = ( excluded ) => {
430
431
if ( excluded . indexOf ( process . env . PARSE_SERVER_TEST_DB ) >= 0 ) {
431
432
return xit ;
432
433
} else {
433
434
return fit ;
434
435
}
435
436
} ;
436
437
437
- global . describe_only_db = db => {
438
+ global . describe_only_db = ( db ) => {
438
439
if ( process . env . PARSE_SERVER_TEST_DB == db ) {
439
440
return describe ;
440
441
} else if ( ! process . env . PARSE_SERVER_TEST_DB && db == 'mongo' ) {
@@ -444,7 +445,7 @@ global.describe_only_db = db => {
444
445
}
445
446
} ;
446
447
447
- global . describe_only = validator => {
448
+ global . describe_only = ( validator ) => {
448
449
if ( validator ( ) ) {
449
450
return describe ;
450
451
} else {
@@ -453,7 +454,7 @@ global.describe_only = validator => {
453
454
} ;
454
455
455
456
const libraryCache = { } ;
456
- jasmine . mockLibrary = function ( library , name , mock ) {
457
+ jasmine . mockLibrary = function ( library , name , mock ) {
457
458
const original = require ( library ) [ name ] ;
458
459
if ( ! libraryCache [ library ] ) {
459
460
libraryCache [ library ] = { } ;
@@ -462,7 +463,7 @@ jasmine.mockLibrary = function(library, name, mock) {
462
463
libraryCache [ library ] [ name ] = original ;
463
464
} ;
464
465
465
- jasmine . restoreLibrary = function ( library , name ) {
466
+ jasmine . restoreLibrary = function ( library , name ) {
466
467
if ( ! libraryCache [ library ] || ! libraryCache [ library ] [ name ] ) {
467
468
throw 'Can not find library ' + library + ' ' + name ;
468
469
}
0 commit comments