@@ -28,7 +28,7 @@ describe('a GlobalConfig', () => {
28
28
} ,
29
29
query ,
30
30
{
31
- params : { companies : [ 'US' , 'DK' ] , internalParam : 'internal' } ,
31
+ params : { companies : [ 'US' , 'DK' ] , counter : 20 , internalParam : 'internal' } ,
32
32
masterKeyOnly : { internalParam : true } ,
33
33
}
34
34
)
@@ -114,6 +114,34 @@ describe('a GlobalConfig', () => {
114
114
} ) ;
115
115
} ) ;
116
116
117
+ it_only_db ( 'mongo' ) ( 'can addUnique' , async ( ) => {
118
+ await Parse . Config . save ( { companies : { __op : 'AddUnique' , objects : [ 'PA' , 'RS' , 'E' ] } } ) ;
119
+ const config = await Parse . Config . get ( ) ;
120
+ const companies = config . get ( 'companies' ) ;
121
+ expect ( companies ) . toEqual ( [ 'US' , 'DK' , 'PA' , 'RS' , 'E' ] ) ;
122
+ } ) ;
123
+
124
+ it_only_db ( 'mongo' ) ( 'can add to array' , async ( ) => {
125
+ await Parse . Config . save ( { companies : { __op : 'Add' , objects : [ 'PA' ] } } ) ;
126
+ const config = await Parse . Config . get ( ) ;
127
+ const companies = config . get ( 'companies' ) ;
128
+ expect ( companies ) . toEqual ( [ 'US' , 'DK' , 'PA' ] ) ;
129
+ } ) ;
130
+
131
+ it_only_db ( 'mongo' ) ( 'can remove from array' , async ( ) => {
132
+ await Parse . Config . save ( { companies : { __op : 'Remove' , objects : [ 'US' ] } } ) ;
133
+ const config = await Parse . Config . get ( ) ;
134
+ const companies = config . get ( 'companies' ) ;
135
+ expect ( companies ) . toEqual ( [ 'DK' ] ) ;
136
+ } ) ;
137
+
138
+ it ( 'can increment' , async ( ) => {
139
+ await Parse . Config . save ( { counter : { __op : 'Increment' , amount : 49 } } ) ;
140
+ const config = await Parse . Config . get ( ) ;
141
+ const counter = config . get ( 'counter' ) ;
142
+ expect ( counter ) . toEqual ( 69 ) ;
143
+ } ) ;
144
+
117
145
it ( 'can add and retrive files' , done => {
118
146
request ( {
119
147
method : 'PUT' ,
@@ -165,6 +193,7 @@ describe('a GlobalConfig', () => {
165
193
body : {
166
194
params : {
167
195
companies : { __op : 'Delete' } ,
196
+ counter : { __op : 'Delete' } ,
168
197
internalParam : { __op : 'Delete' } ,
169
198
foo : 'bar' ,
170
199
} ,
@@ -183,6 +212,7 @@ describe('a GlobalConfig', () => {
183
212
try {
184
213
expect ( response . status ) . toEqual ( 200 ) ;
185
214
expect ( body . params . companies ) . toBeUndefined ( ) ;
215
+ expect ( body . params . counter ) . toBeUndefined ( ) ;
186
216
expect ( body . params . foo ) . toBe ( 'bar' ) ;
187
217
expect ( Object . keys ( body . params ) . length ) . toBe ( 1 ) ;
188
218
} catch ( e ) {
0 commit comments