@@ -92,9 +92,7 @@ describe('cloud validator', () => {
92
92
} ,
93
93
async ( ) => {
94
94
await new Promise ( resolve => {
95
- setTimeout ( ( ) => {
96
- resolve ( ) ;
97
- } , 1000 ) ;
95
+ setTimeout ( resolve , 1000 ) ;
98
96
} ) ;
99
97
throw 'async error' ;
100
98
}
@@ -132,7 +130,7 @@ describe('cloud validator', () => {
132
130
await Parse . Cloud . run ( 'myFunction' ) ;
133
131
} ) ;
134
132
135
- it ( 'require user on cloud functions' , done => {
133
+ it ( 'require user on cloud functions' , async done => {
136
134
Parse . Cloud . define (
137
135
'hello1' ,
138
136
( ) => {
@@ -142,16 +140,14 @@ describe('cloud validator', () => {
142
140
requireUser : true ,
143
141
}
144
142
) ;
145
-
146
- Parse . Cloud . run ( 'hello1' , { } )
147
- . then ( ( ) => {
148
- fail ( 'function should have failed.' ) ;
149
- } )
150
- . catch ( error => {
151
- expect ( error . code ) . toEqual ( Parse . Error . VALIDATION_ERROR ) ;
152
- expect ( error . message ) . toEqual ( 'Validation failed. Please login to continue.' ) ;
153
- done ( ) ;
154
- } ) ;
143
+ try {
144
+ await Parse . Cloud . run ( 'hello1' , { } ) ;
145
+ fail ( 'function should have failed.' ) ;
146
+ } catch ( error ) {
147
+ expect ( error . code ) . toEqual ( Parse . Error . VALIDATION_ERROR ) ;
148
+ expect ( error . message ) . toEqual ( 'Validation failed. Please login to continue.' ) ;
149
+ done ( ) ;
150
+ }
155
151
} ) ;
156
152
157
153
it ( 'require master on cloud functions' , done => {
@@ -605,16 +601,10 @@ describe('cloud validator', () => {
605
601
expect ( obj . get ( 'foo' ) ) . toBe ( 'bar' ) ;
606
602
607
603
const query = new Parse . Query ( 'beforeFind' ) ;
608
- try {
609
- const first = await query . first ( { useMasterKey : true } ) ;
610
- expect ( first ) . toBeDefined ( ) ;
611
- expect ( first . id ) . toBe ( obj . id ) ;
612
- done ( ) ;
613
- } catch ( e ) {
614
- console . log ( e ) ;
615
- console . log ( e . code ) ;
616
- throw e ;
617
- }
604
+ const first = await query . first ( { useMasterKey : true } ) ;
605
+ expect ( first ) . toBeDefined ( ) ;
606
+ expect ( first . id ) . toBe ( obj . id ) ;
607
+ done ( ) ;
618
608
} ) ;
619
609
620
610
it ( 'basic beforeDelete skipWithMasterKey' , async function ( done ) {
@@ -1429,6 +1419,35 @@ describe('cloud validator', () => {
1429
1419
}
1430
1420
} ) ;
1431
1421
1422
+ it ( 'does not log on valid config' , ( ) => {
1423
+ const logger = require ( '../lib/logger' ) . logger ;
1424
+ spyOn ( logger , 'error' ) . and . callFake ( ( ) => { } ) ;
1425
+ Parse . Cloud . define ( 'myFunction' , ( ) => { } , {
1426
+ requireUser : true ,
1427
+ requireMaster : true ,
1428
+ validateMasterKey : false ,
1429
+ skipWithMasterKey : true ,
1430
+ requireUserKeys : {
1431
+ Acc : {
1432
+ constant : true ,
1433
+ options : [ 'A' , 'B' ] ,
1434
+ required : true ,
1435
+ default : 'f' ,
1436
+ type : String ,
1437
+ } ,
1438
+ } ,
1439
+ fields : {
1440
+ Acc : {
1441
+ constant : true ,
1442
+ options : [ 'A' , 'B' ] ,
1443
+ required : true ,
1444
+ default : 'f' ,
1445
+ type : String ,
1446
+ } ,
1447
+ } ,
1448
+ } ) ;
1449
+ expect ( logger . error ) . not . toHaveBeenCalled ( ) ;
1450
+ } ) ;
1432
1451
it ( 'Logs on invalid config' , ( ) => {
1433
1452
const logger = require ( '../lib/logger' ) . logger ;
1434
1453
spyOn ( logger , 'error' ) . and . callFake ( ( ) => { } ) ;
0 commit comments