@@ -28,7 +28,7 @@ describe('a GlobalConfig', () => {
2828 } ,
2929 query ,
3030 {
31- params : { companies : [ 'US' , 'DK' ] , internalParam : 'internal' } ,
31+ params : { companies : [ 'US' , 'DK' ] , counter : 20 , internalParam : 'internal' } ,
3232 masterKeyOnly : { internalParam : true } ,
3333 }
3434 )
@@ -114,6 +114,34 @@ describe('a GlobalConfig', () => {
114114 } ) ;
115115 } ) ;
116116
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+
117145 it ( 'can add and retrive files' , done => {
118146 request ( {
119147 method : 'PUT' ,
@@ -165,6 +193,7 @@ describe('a GlobalConfig', () => {
165193 body : {
166194 params : {
167195 companies : { __op : 'Delete' } ,
196+ counter : { __op : 'Delete' } ,
168197 internalParam : { __op : 'Delete' } ,
169198 foo : 'bar' ,
170199 } ,
@@ -183,6 +212,7 @@ describe('a GlobalConfig', () => {
183212 try {
184213 expect ( response . status ) . toEqual ( 200 ) ;
185214 expect ( body . params . companies ) . toBeUndefined ( ) ;
215+ expect ( body . params . counter ) . toBeUndefined ( ) ;
186216 expect ( body . params . foo ) . toBe ( 'bar' ) ;
187217 expect ( Object . keys ( body . params ) . length ) . toBe ( 1 ) ;
188218 } catch ( e ) {
0 commit comments