@@ -7,7 +7,7 @@ const { expectedGreenResults, expectedPurpleResults, expectedPinkResults } = req
77jest . mock ( 'node-fetch' , ( ) => {
88 return jest . fn ( ) . mockImplementation ( ( url ) => {
99
10- const sdkUrl = 'https://sdk.test.io/api/splitChanges?s=1.1 &since=-1' ;
10+ const sdkUrl = 'https://sdk.test.io/api/splitChanges?s=1.3 &since=-1' ;
1111 const splitChange2 = require ( '../../utils/mocks/splitchanges.since.-1.till.1602796638344.json' ) ;
1212 if ( url . startsWith ( sdkUrl ) ) return Promise . resolve ( { status : 200 , json : ( ) => ( splitChange2 ) , ok : true } ) ;
1313
@@ -273,4 +273,44 @@ describe('get-treatments-by-sets', () => {
273273 . set ( 'Authorization' , 'key_pink' ) ;
274274 expectOkMultipleResults ( response , 200 , expectedPinkResults , 5 ) ;
275275 } ) ;
276+
277+ test ( 'should be 400 if options.properties is invalid (GET)' , async ( ) => {
278+ const expected = [
279+ 'options.properties must only contain boolean, string, or number values.'
280+ ] ;
281+ const response = await request ( app )
282+ . get ( '/client/get-treatments-by-sets?key=test&flag-sets=set_green&options={"properties":{"invalid":[1,2,3]}}' )
283+ . set ( 'Authorization' , 'key_green' ) ;
284+ expectErrorContaining ( response , 400 , expected ) ;
285+ } ) ;
286+
287+ test ( 'should be 400 if options.properties is invalid (POST)' , async ( ) => {
288+ const expected = [
289+ 'options.properties must only contain boolean, string, or number values.'
290+ ] ;
291+ const response = await request ( app )
292+ . post ( '/client/get-treatments-by-sets?key=test&flag-sets=set_green' )
293+ . send ( {
294+ options : { properties : { invalid : [ 1 , 2 , 3 ] } } ,
295+ } )
296+ . set ( 'Authorization' , 'key_green' ) ;
297+ expectErrorContaining ( response , 400 , expected ) ;
298+ } ) ;
299+
300+ test ( 'should be 200 if options.properties is valid (GET)' , async ( ) => {
301+ const response = await request ( app )
302+ . get ( '/client/get-treatments-by-sets?key=test&flag-sets=set_green&options={"properties":{"package":"premium","admin":true,"discount":50}}' )
303+ . set ( 'Authorization' , 'key_green' ) ;
304+ expect ( response . status ) . toBe ( 200 ) ;
305+ } ) ;
306+
307+ test ( 'should be 200 if options.properties is valid (POST)' , async ( ) => {
308+ const response = await request ( app )
309+ . post ( '/client/get-treatments-by-sets?key=test&flag-sets=set_green' )
310+ . send ( {
311+ options : { properties : { package : 'premium' , admin : true , discount : 50 } } ,
312+ } )
313+ . set ( 'Authorization' , 'key_green' ) ;
314+ expect ( response . status ) . toBe ( 200 ) ;
315+ } ) ;
276316} ) ;
0 commit comments