@@ -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 => {
@@ -587,16 +583,10 @@ describe('cloud validator', () => {
587
583
expect ( obj . get ( 'foo' ) ) . toBe ( 'bar' ) ;
588
584
589
585
const query = new Parse . Query ( 'beforeFind' ) ;
590
- try {
591
- const first = await query . first ( { useMasterKey : true } ) ;
592
- expect ( first ) . toBeDefined ( ) ;
593
- expect ( first . id ) . toBe ( obj . id ) ;
594
- done ( ) ;
595
- } catch ( e ) {
596
- console . log ( e ) ;
597
- console . log ( e . code ) ;
598
- throw e ;
599
- }
586
+ const first = await query . first ( { useMasterKey : true } ) ;
587
+ expect ( first ) . toBeDefined ( ) ;
588
+ expect ( first . id ) . toBe ( obj . id ) ;
589
+ done ( ) ;
600
590
} ) ;
601
591
602
592
it ( 'basic beforeDelete skipWithMasterKey' , async function ( done ) {
@@ -1267,6 +1257,35 @@ describe('cloud validator', () => {
1267
1257
}
1268
1258
} ) ;
1269
1259
1260
+ it ( 'does not log on valid config' , ( ) => {
1261
+ const logger = require ( '../lib/logger' ) . logger ;
1262
+ spyOn ( logger , 'error' ) . and . callFake ( ( ) => { } ) ;
1263
+ Parse . Cloud . define ( 'myFunction' , ( ) => { } , {
1264
+ requireUser : true ,
1265
+ requireMaster : true ,
1266
+ validateMasterKey : false ,
1267
+ skipWithMasterKey : true ,
1268
+ requireUserKeys : {
1269
+ Acc : {
1270
+ constant : true ,
1271
+ options : [ 'A' , 'B' ] ,
1272
+ required : true ,
1273
+ default : 'f' ,
1274
+ type : String ,
1275
+ } ,
1276
+ } ,
1277
+ fields : {
1278
+ Acc : {
1279
+ constant : true ,
1280
+ options : [ 'A' , 'B' ] ,
1281
+ required : true ,
1282
+ default : 'f' ,
1283
+ type : String ,
1284
+ } ,
1285
+ } ,
1286
+ } ) ;
1287
+ expect ( logger . error ) . not . toHaveBeenCalled ( ) ;
1288
+ } ) ;
1270
1289
it ( 'Logs on invalid config' , ( ) => {
1271
1290
const logger = require ( '../lib/logger' ) . logger ;
1272
1291
spyOn ( logger , 'error' ) . and . callFake ( ( ) => { } ) ;
0 commit comments