@@ -5,21 +5,21 @@ var Parse = require('parse/node').Parse;
5
5
let Config = require ( '../src/Config' ) ;
6
6
7
7
describe ( 'a GlobalConfig' , ( ) => {
8
- beforeEach ( function ( done ) {
8
+ beforeEach ( function ( done ) {
9
9
let config = new Config ( 'test' ) ;
10
- config . database . rawCollection ( '_GlobalConfig' )
11
- . then ( coll => coll . updateOne ( { '_id' : 1 } , { $set : { params : { companies : [ 'US' , 'DK' ] } } } , { upsert : true } ) )
10
+ config . database . adaptiveCollection ( '_GlobalConfig' )
11
+ . then ( coll => coll . upsertOne ( { '_id' : 1 } , { $set : { params : { companies : [ 'US' , 'DK' ] } } } ) )
12
12
. then ( done ( ) ) ;
13
13
} ) ;
14
14
15
15
it ( 'can be retrieved' , ( done ) => {
16
16
request . get ( {
17
- url : 'http://localhost:8378/1/config' ,
18
- json : true ,
17
+ url : 'http://localhost:8378/1/config' ,
18
+ json : true ,
19
19
headers : {
20
20
'X-Parse-Application-Id' : 'test' ,
21
- 'X-Parse-Master-Key' : 'test' ,
22
- } ,
21
+ 'X-Parse-Master-Key' : 'test'
22
+ }
23
23
} , ( error , response , body ) => {
24
24
expect ( response . statusCode ) . toEqual ( 200 ) ;
25
25
expect ( body . params . companies ) . toEqual ( [ 'US' , 'DK' ] ) ;
@@ -29,13 +29,13 @@ describe('a GlobalConfig', () => {
29
29
30
30
it ( 'can be updated when a master key exists' , ( done ) => {
31
31
request . put ( {
32
- url : 'http://localhost:8378/1/config' ,
33
- json : true ,
34
- body : { params : { companies : [ 'US' , 'DK' , 'SE' ] } } ,
32
+ url : 'http://localhost:8378/1/config' ,
33
+ json : true ,
34
+ body : { params : { companies : [ 'US' , 'DK' , 'SE' ] } } ,
35
35
headers : {
36
36
'X-Parse-Application-Id' : 'test' ,
37
- 'X-Parse-Master-Key' : 'test'
38
- } ,
37
+ 'X-Parse-Master-Key' : 'test'
38
+ }
39
39
} , ( error , response , body ) => {
40
40
expect ( response . statusCode ) . toEqual ( 200 ) ;
41
41
expect ( body . result ) . toEqual ( true ) ;
@@ -45,35 +45,35 @@ describe('a GlobalConfig', () => {
45
45
46
46
it ( 'fail to update if master key is missing' , ( done ) => {
47
47
request . put ( {
48
- url : 'http://localhost:8378/1/config' ,
49
- json : true ,
50
- body : { params : { companies : [ ] } } ,
48
+ url : 'http://localhost:8378/1/config' ,
49
+ json : true ,
50
+ body : { params : { companies : [ ] } } ,
51
51
headers : {
52
52
'X-Parse-Application-Id' : 'test' ,
53
- 'X-Parse-REST-API-Key' : 'rest'
54
- } ,
53
+ 'X-Parse-REST-API-Key' : 'rest'
54
+ }
55
55
} , ( error , response , body ) => {
56
56
expect ( response . statusCode ) . toEqual ( 403 ) ;
57
57
expect ( body . error ) . toEqual ( 'unauthorized: master key is required' ) ;
58
58
done ( ) ;
59
59
} ) ;
60
- } ) ;
60
+ } ) ;
61
61
62
62
it ( 'failed getting config when it is missing' , ( done ) => {
63
63
let config = new Config ( 'test' ) ;
64
- config . database . rawCollection ( '_GlobalConfig' )
65
- . then ( coll => coll . deleteOne ( { '_id' : 1 } , { } , { } ) )
66
- . then ( _ => {
64
+ config . database . adaptiveCollection ( '_GlobalConfig' )
65
+ . then ( coll => coll . deleteOne ( { '_id' : 1 } ) )
66
+ . then ( ( ) => {
67
67
request . get ( {
68
- url : 'http://localhost:8378/1/config' ,
69
- json : true ,
68
+ url : 'http://localhost:8378/1/config' ,
69
+ json : true ,
70
70
headers : {
71
71
'X-Parse-Application-Id' : 'test' ,
72
- 'X-Parse-Master-Key' : 'test' ,
73
- } ,
72
+ 'X-Parse-Master-Key' : 'test'
73
+ }
74
74
} , ( error , response , body ) => {
75
- expect ( response . statusCode ) . toEqual ( 404 ) ;
76
- expect ( body . code ) . toEqual ( Parse . Error . INVALID_KEY_NAME ) ;
75
+ expect ( response . statusCode ) . toEqual ( 200 ) ;
76
+ expect ( body . params ) . toEqual ( { } ) ;
77
77
done ( ) ;
78
78
} ) ;
79
79
} ) ;
0 commit comments