@@ -24,7 +24,7 @@ const headers = {
24
24
} ;
25
25
26
26
describe_only_db ( 'mongo' ) ( 'miscellaneous' , ( ) => {
27
- it ( 'test rest_create_app' , function ( done ) {
27
+ it ( 'test rest_create_app' , function ( done ) {
28
28
let appId ;
29
29
Parse . _request ( 'POST' , 'rest_create_app' )
30
30
. then ( res => {
@@ -57,19 +57,19 @@ describe_only_db('mongo')('miscellaneous', () => {
57
57
} ) ;
58
58
} ) ;
59
59
60
- describe ( 'miscellaneous' , function ( ) {
61
- it ( 'create a GameScore object' , function ( done ) {
60
+ describe ( 'miscellaneous' , function ( ) {
61
+ it ( 'create a GameScore object' , function ( done ) {
62
62
const obj = new Parse . Object ( 'GameScore' ) ;
63
63
obj . set ( 'score' , 1337 ) ;
64
- obj . save ( ) . then ( function ( obj ) {
64
+ obj . save ( ) . then ( function ( obj ) {
65
65
expect ( typeof obj . id ) . toBe ( 'string' ) ;
66
66
expect ( typeof obj . createdAt . toGMTString ( ) ) . toBe ( 'string' ) ;
67
67
done ( ) ;
68
68
} , done . fail ) ;
69
69
} ) ;
70
70
71
- it ( 'get a TestObject' , function ( done ) {
72
- create ( { bloop : 'blarg' } , async function ( obj ) {
71
+ it ( 'get a TestObject' , function ( done ) {
72
+ create ( { bloop : 'blarg' } , async function ( obj ) {
73
73
const t2 = new TestObject ( { objectId : obj . id } ) ;
74
74
const obj2 = await t2 . fetch ( ) ;
75
75
expect ( obj2 . get ( 'bloop' ) ) . toEqual ( 'blarg' ) ;
@@ -79,8 +79,8 @@ describe('miscellaneous', function() {
79
79
} ) ;
80
80
} ) ;
81
81
82
- it ( 'create a valid parse user' , function ( done ) {
83
- createTestUser ( ) . then ( function ( data ) {
82
+ it ( 'create a valid parse user' , function ( done ) {
83
+ createTestUser ( ) . then ( function ( data ) {
84
84
expect ( data . id ) . not . toBeUndefined ( ) ;
85
85
expect ( data . getSessionToken ( ) ) . not . toBeUndefined ( ) ;
86
86
expect ( data . get ( 'password' ) ) . toBeUndefined ( ) ;
@@ -297,8 +297,8 @@ describe('miscellaneous', function() {
297
297
} ) ;
298
298
} ) ;
299
299
300
- it ( 'succeed in logging in' , function ( done ) {
301
- createTestUser ( ) . then ( async function ( u ) {
300
+ it ( 'succeed in logging in' , function ( done ) {
301
+ createTestUser ( ) . then ( async function ( u ) {
302
302
expect ( typeof u . id ) . toEqual ( 'string' ) ;
303
303
304
304
const user = await Parse . User . logIn ( 'test' , 'moon-y' ) ;
@@ -310,7 +310,7 @@ describe('miscellaneous', function() {
310
310
} , fail ) ;
311
311
} ) ;
312
312
313
- it ( 'increment with a user object' , function ( done ) {
313
+ it ( 'increment with a user object' , function ( done ) {
314
314
createTestUser ( )
315
315
. then ( user => {
316
316
user . increment ( 'foo' ) ;
@@ -338,7 +338,7 @@ describe('miscellaneous', function() {
338
338
) ;
339
339
} ) ;
340
340
341
- it ( 'save various data types' , function ( done ) {
341
+ it ( 'save various data types' , function ( done ) {
342
342
const obj = new TestObject ( ) ;
343
343
obj . set ( 'date' , new Date ( ) ) ;
344
344
obj . set ( 'array' , [ 1 , 2 , 3 ] ) ;
@@ -358,7 +358,7 @@ describe('miscellaneous', function() {
358
358
} ) ;
359
359
} ) ;
360
360
361
- it ( 'query with limit' , function ( done ) {
361
+ it ( 'query with limit' , function ( done ) {
362
362
const baz = new TestObject ( { foo : 'baz' } ) ;
363
363
const qux = new TestObject ( { foo : 'qux' } ) ;
364
364
baz
@@ -383,7 +383,7 @@ describe('miscellaneous', function() {
383
383
) ;
384
384
} ) ;
385
385
386
- it ( 'query without limit get default 100 records' , function ( done ) {
386
+ it ( 'query without limit get default 100 records' , function ( done ) {
387
387
const objects = [ ] ;
388
388
for ( let i = 0 ; i < 150 ; i ++ ) {
389
389
objects . push ( new TestObject ( { name : 'name' + i } ) ) ;
@@ -404,7 +404,7 @@ describe('miscellaneous', function() {
404
404
) ;
405
405
} ) ;
406
406
407
- it ( 'basic saveAll' , function ( done ) {
407
+ it ( 'basic saveAll' , function ( done ) {
408
408
const alpha = new TestObject ( { letter : 'alpha' } ) ;
409
409
const beta = new TestObject ( { letter : 'beta' } ) ;
410
410
Parse . Object . saveAll ( [ alpha , beta ] )
@@ -425,26 +425,26 @@ describe('miscellaneous', function() {
425
425
) ;
426
426
} ) ;
427
427
428
- it ( 'test beforeSave set object acl success' , function ( done ) {
428
+ it ( 'test beforeSave set object acl success' , function ( done ) {
429
429
const acl = new Parse . ACL ( {
430
430
'*' : { read : true , write : false } ,
431
431
} ) ;
432
- Parse . Cloud . beforeSave ( 'BeforeSaveAddACL' , function ( req ) {
432
+ Parse . Cloud . beforeSave ( 'BeforeSaveAddACL' , function ( req ) {
433
433
req . object . setACL ( acl ) ;
434
434
} ) ;
435
435
436
436
const obj = new Parse . Object ( 'BeforeSaveAddACL' ) ;
437
437
obj . set ( 'lol' , true ) ;
438
438
obj . save ( ) . then (
439
- function ( ) {
439
+ function ( ) {
440
440
const query = new Parse . Query ( 'BeforeSaveAddACL' ) ;
441
441
query . get ( obj . id ) . then (
442
- function ( objAgain ) {
442
+ function ( objAgain ) {
443
443
expect ( objAgain . get ( 'lol' ) ) . toBeTruthy ( ) ;
444
444
expect ( objAgain . getACL ( ) . equals ( acl ) ) ;
445
445
done ( ) ;
446
446
} ,
447
- function ( error ) {
447
+ function ( error ) {
448
448
fail ( error ) ;
449
449
done ( ) ;
450
450
}
@@ -667,10 +667,10 @@ describe('miscellaneous', function() {
667
667
} ) ;
668
668
} ) ;
669
669
670
- it ( 'test afterSave get full object on create and update' , function ( done ) {
670
+ it ( 'test afterSave get full object on create and update' , function ( done ) {
671
671
let triggerTime = 0 ;
672
672
// Register a mock beforeSave hook
673
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
673
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
674
674
const object = req . object ;
675
675
expect ( object instanceof Parse . Object ) . toBeTruthy ( ) ;
676
676
expect ( object . id ) . not . toBeUndefined ( ) ;
@@ -694,29 +694,29 @@ describe('miscellaneous', function() {
694
694
obj . set ( 'fooAgain' , 'barAgain' ) ;
695
695
obj
696
696
. save ( )
697
- . then ( function ( ) {
697
+ . then ( function ( ) {
698
698
// We only update foo
699
699
obj . set ( 'foo' , 'baz' ) ;
700
700
return obj . save ( ) ;
701
701
} )
702
702
. then (
703
- function ( ) {
703
+ function ( ) {
704
704
// Make sure the checking has been triggered
705
705
expect ( triggerTime ) . toBe ( 2 ) ;
706
706
done ( ) ;
707
707
} ,
708
- function ( error ) {
708
+ function ( error ) {
709
709
fail ( error ) ;
710
710
done ( ) ;
711
711
}
712
712
) ;
713
713
} ) ;
714
714
715
- it ( 'test afterSave get original object on update' , function ( done ) {
715
+ it ( 'test afterSave get original object on update' , function ( done ) {
716
716
let triggerTime = 0 ;
717
717
// Register a mock beforeSave hook
718
718
719
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
719
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
720
720
const object = req . object ;
721
721
expect ( object instanceof Parse . Object ) . toBeTruthy ( ) ;
722
722
expect ( object . get ( 'fooAgain' ) ) . toEqual ( 'barAgain' ) ;
@@ -750,18 +750,18 @@ describe('miscellaneous', function() {
750
750
obj . set ( 'fooAgain' , 'barAgain' ) ;
751
751
obj
752
752
. save ( )
753
- . then ( function ( ) {
753
+ . then ( function ( ) {
754
754
// We only update foo
755
755
obj . set ( 'foo' , 'baz' ) ;
756
756
return obj . save ( ) ;
757
757
} )
758
758
. then (
759
- function ( ) {
759
+ function ( ) {
760
760
// Make sure the checking has been triggered
761
761
expect ( triggerTime ) . toBe ( 2 ) ;
762
762
done ( ) ;
763
763
} ,
764
- function ( error ) {
764
+ function ( error ) {
765
765
jfail ( error ) ;
766
766
done ( ) ;
767
767
}
@@ -771,7 +771,7 @@ describe('miscellaneous', function() {
771
771
it ( 'test afterSave get full original object even req auth can not query it' , done => {
772
772
let triggerTime = 0 ;
773
773
// Register a mock beforeSave hook
774
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
774
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
775
775
const object = req . object ;
776
776
const originalObject = req . original ;
777
777
if ( triggerTime == 0 ) {
@@ -802,18 +802,18 @@ describe('miscellaneous', function() {
802
802
obj . setACL ( acl ) ;
803
803
obj
804
804
. save ( )
805
- . then ( function ( ) {
805
+ . then ( function ( ) {
806
806
// We only update foo
807
807
obj . set ( 'foo' , 'baz' ) ;
808
808
return obj . save ( ) ;
809
809
} )
810
810
. then (
811
- function ( ) {
811
+ function ( ) {
812
812
// Make sure the checking has been triggered
813
813
expect ( triggerTime ) . toBe ( 2 ) ;
814
814
done ( ) ;
815
815
} ,
816
- function ( error ) {
816
+ function ( error ) {
817
817
jfail ( error ) ;
818
818
done ( ) ;
819
819
}
@@ -823,7 +823,7 @@ describe('miscellaneous', function() {
823
823
it ( 'afterSave flattens custom operations' , done => {
824
824
let triggerTime = 0 ;
825
825
// Register a mock beforeSave hook
826
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
826
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
827
827
const object = req . object ;
828
828
expect ( object instanceof Parse . Object ) . toBeTruthy ( ) ;
829
829
const originalObject = req . original ;
@@ -865,7 +865,7 @@ describe('miscellaneous', function() {
865
865
it ( 'beforeSave receives ACL' , done => {
866
866
let triggerTime = 0 ;
867
867
// Register a mock beforeSave hook
868
- Parse . Cloud . beforeSave ( 'GameScore' , function ( req ) {
868
+ Parse . Cloud . beforeSave ( 'GameScore' , function ( req ) {
869
869
const object = req . object ;
870
870
if ( triggerTime == 0 ) {
871
871
const acl = object . getACL ( ) ;
@@ -909,7 +909,7 @@ describe('miscellaneous', function() {
909
909
it ( 'afterSave receives ACL' , done => {
910
910
let triggerTime = 0 ;
911
911
// Register a mock beforeSave hook
912
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
912
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
913
913
const object = req . object ;
914
914
if ( triggerTime == 0 ) {
915
915
const acl = object . getACL ( ) ;
@@ -1057,14 +1057,14 @@ describe('miscellaneous', function() {
1057
1057
) ;
1058
1058
} ) ;
1059
1059
1060
- it ( 'test beforeSave/afterSave get installationId' , function ( done ) {
1060
+ it ( 'test beforeSave/afterSave get installationId' , function ( done ) {
1061
1061
let triggerTime = 0 ;
1062
- Parse . Cloud . beforeSave ( 'GameScore' , function ( req ) {
1062
+ Parse . Cloud . beforeSave ( 'GameScore' , function ( req ) {
1063
1063
triggerTime ++ ;
1064
1064
expect ( triggerTime ) . toEqual ( 1 ) ;
1065
1065
expect ( req . installationId ) . toEqual ( 'yolo' ) ;
1066
1066
} ) ;
1067
- Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
1067
+ Parse . Cloud . afterSave ( 'GameScore' , function ( req ) {
1068
1068
triggerTime ++ ;
1069
1069
expect ( triggerTime ) . toEqual ( 2 ) ;
1070
1070
expect ( req . installationId ) . toEqual ( 'yolo' ) ;
@@ -1087,14 +1087,14 @@ describe('miscellaneous', function() {
1087
1087
} ) ;
1088
1088
} ) ;
1089
1089
1090
- it ( 'test beforeDelete/afterDelete get installationId' , function ( done ) {
1090
+ it ( 'test beforeDelete/afterDelete get installationId' , function ( done ) {
1091
1091
let triggerTime = 0 ;
1092
- Parse . Cloud . beforeDelete ( 'GameScore' , function ( req ) {
1092
+ Parse . Cloud . beforeDelete ( 'GameScore' , function ( req ) {
1093
1093
triggerTime ++ ;
1094
1094
expect ( triggerTime ) . toEqual ( 1 ) ;
1095
1095
expect ( req . installationId ) . toEqual ( 'yolo' ) ;
1096
1096
} ) ;
1097
- Parse . Cloud . afterDelete ( 'GameScore' , function ( req ) {
1097
+ Parse . Cloud . afterDelete ( 'GameScore' , function ( req ) {
1098
1098
triggerTime ++ ;
1099
1099
expect ( triggerTime ) . toEqual ( 2 ) ;
1100
1100
expect ( req . installationId ) . toEqual ( 'yolo' ) ;
@@ -1170,33 +1170,6 @@ describe('miscellaneous', function() {
1170
1170
} ) ;
1171
1171
} ) ;
1172
1172
1173
- it ( 'test cloud function parameter validation' , done => {
1174
- // Register a function with validation
1175
- Parse . Cloud . define (
1176
- 'functionWithParameterValidationFailure' ,
1177
- ( ) => {
1178
- return 'noway' ;
1179
- } ,
1180
- request => {
1181
- return request . params . success === 100 ;
1182
- }
1183
- ) ;
1184
-
1185
- Parse . Cloud . run ( 'functionWithParameterValidationFailure' , {
1186
- success : 500 ,
1187
- } ) . then (
1188
- ( ) => {
1189
- fail ( 'Validation should not have succeeded' ) ;
1190
- done ( ) ;
1191
- } ,
1192
- e => {
1193
- expect ( e . code ) . toEqual ( 142 ) ;
1194
- expect ( e . message ) . toEqual ( 'Validation failed.' ) ;
1195
- done ( ) ;
1196
- }
1197
- ) ;
1198
- } ) ;
1199
-
1200
1173
it ( 'can handle null params in cloud functions (regression test for #1742)' , done => {
1201
1174
Parse . Cloud . define ( 'func' , request => {
1202
1175
expect ( request . params . nullParam ) . toEqual ( null ) ;
@@ -1715,10 +1688,7 @@ describe('miscellaneous', function() {
1715
1688
1716
1689
it ( 'purge empty class' , done => {
1717
1690
const testSchema = new Parse . Schema ( 'UnknownClass' ) ;
1718
- testSchema
1719
- . purge ( )
1720
- . then ( done )
1721
- . catch ( done . fail ) ;
1691
+ testSchema . purge ( ) . then ( done ) . catch ( done . fail ) ;
1722
1692
} ) ;
1723
1693
1724
1694
it ( 'should not update schema beforeSave #2672' , done => {
0 commit comments