@@ -280,6 +280,49 @@ describe(`ConstructorIO${bundledDescriptionSuffix}`, () => {
280280 expect ( instance . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
281281 } ) ;
282282
283+ it ( 'Should filter out non-string testCell values in constructor' , ( ) => {
284+ const testCells = {
285+ valid : 'bar' ,
286+ nullVal : null ,
287+ numVal : 123 ,
288+ objVal : { nested : 'value' } ,
289+ emptyStr : '' ,
290+ boolean : true ,
291+ } ;
292+ const instance = new ConstructorIO ( {
293+ apiKey : validApiKey ,
294+ testCells,
295+ } ) ;
296+
297+ expect ( instance . options . testCells ) . to . deep . equal ( { valid : 'bar' } ) ;
298+ } ) ;
299+
300+ it ( 'Should filter out non-string testCell values in setClientOptions' , ( ) => {
301+ const instance = new ConstructorIO ( {
302+ apiKey : validApiKey ,
303+ testCells : { initial : 'value' } ,
304+ } ) ;
305+
306+ instance . setClientOptions ( {
307+ testCells : {
308+ valid : 'baz' ,
309+ nullVal : null ,
310+ numVal : 42 ,
311+ } ,
312+ } ) ;
313+
314+ expect ( instance . options . testCells ) . to . deep . equal ( { valid : 'baz' } ) ;
315+ } ) ;
316+
317+ it ( 'Should handle null testCells in constructor without error' , ( ) => {
318+ const instance = new ConstructorIO ( {
319+ apiKey : validApiKey ,
320+ testCells : null ,
321+ } ) ;
322+
323+ expect ( instance . options . testCells ) . to . deep . equal ( { } ) ;
324+ } ) ;
325+
283326 it ( 'Should update the client options with new sendTrackingEvents value' , ( ) => {
284327 const instance = new ConstructorIO ( {
285328 apiKey : validApiKey ,
@@ -507,22 +550,22 @@ describe(`ConstructorIO${bundledDescriptionSuffix}`, () => {
507550 } ) ;
508551
509552 expect ( instance . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
510- expect ( instance . search . options ) . to . have . property ( 'testCells' ) . to . equal ( oldTestCells ) ;
511- expect ( instance . autocomplete . options ) . to . have . property ( 'testCells' ) . to . equal ( oldTestCells ) ;
512- expect ( instance . browse . options ) . to . have . property ( 'testCells' ) . to . equal ( oldTestCells ) ;
513- expect ( instance . recommendations . options ) . to . have . property ( 'testCells' ) . to . equal ( oldTestCells ) ;
514- expect ( instance . tracker . options ) . to . have . property ( 'testCells' ) . to . equal ( oldTestCells ) ;
553+ expect ( instance . search . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
554+ expect ( instance . autocomplete . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
555+ expect ( instance . browse . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
556+ expect ( instance . recommendations . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
557+ expect ( instance . tracker . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( oldTestCells ) ;
515558
516559 instance . setClientOptions ( {
517560 testCells : newTestCells ,
518561 } ) ;
519562
520563 expect ( instance . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
521- expect ( instance . search . options ) . to . have . property ( 'testCells' ) . to . equal ( newTestCells ) ;
522- expect ( instance . autocomplete . options ) . to . have . property ( 'testCells' ) . to . equal ( newTestCells ) ;
523- expect ( instance . browse . options ) . to . have . property ( 'testCells' ) . to . equal ( newTestCells ) ;
524- expect ( instance . recommendations . options ) . to . have . property ( 'testCells' ) . to . equal ( newTestCells ) ;
525- expect ( instance . tracker . options ) . to . have . property ( 'testCells' ) . to . equal ( newTestCells ) ;
564+ expect ( instance . search . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
565+ expect ( instance . autocomplete . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
566+ expect ( instance . browse . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
567+ expect ( instance . recommendations . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
568+ expect ( instance . tracker . options ) . to . have . property ( 'testCells' ) . to . deep . equal ( newTestCells ) ;
526569 } ) ;
527570
528571 it ( 'Should update the client options with a new user id' , ( ) => {
0 commit comments