1+ import { LDContext } from '../dist' ;
12import { AttributeReference , Context } from '../src' ;
23import ContextFilter from '../src/ContextFilter' ;
34
@@ -416,6 +417,23 @@ describe('when handling mult-kind contexts', () => {
416417 } ,
417418 } ;
418419
420+ const multiWithSingleContext = Context . fromLDContext ( {
421+ kind : 'multi' ,
422+ user : {
423+ key : 'abc' ,
424+ name : 'alphabet' ,
425+ letters : [ 'a' , 'b' , 'c' ] ,
426+ order : 3 ,
427+ object : {
428+ a : 'a' ,
429+ b : 'b' ,
430+ } ,
431+ _meta : {
432+ privateAttributes : [ 'letters' , '/object/b' ] ,
433+ } ,
434+ } ,
435+ } ) ;
436+
419437 it ( 'it should remove attributes from all contexts when all attributes are private.' , ( ) => {
420438 const uf = new ContextFilter ( true , [ ] ) ;
421439 expect ( uf . filter ( orgAndUserContext ) ) . toEqual ( orgAndUserContextAllPrivate ) ;
@@ -430,4 +448,20 @@ describe('when handling mult-kind contexts', () => {
430448 const uf = new ContextFilter ( false , [ new AttributeReference ( 'name' , true ) ] ) ;
431449 expect ( uf . filter ( orgAndUserContext ) ) . toEqual ( orgAndUserGlobalNamePrivate ) ;
432450 } ) ;
451+
452+ it ( 'should produce event with valid single context' , ( ) => {
453+ const uf = new ContextFilter ( false , [ ] ) ;
454+ expect ( uf . filter ( multiWithSingleContext ) ) . toEqual ( {
455+ kind : 'user' ,
456+ _meta : {
457+ redactedAttributes : [ '/object/b' , 'letters' ] ,
458+ } ,
459+ key : 'abc' ,
460+ name : 'alphabet' ,
461+ object : {
462+ a : 'a' ,
463+ } ,
464+ order : 3 ,
465+ } ) ;
466+ } ) ;
433467} ) ;
0 commit comments