File tree Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Expand file tree Collapse file tree 2 files changed +34
-1
lines changed Original file line number Diff line number Diff line change @@ -416,6 +416,23 @@ describe('when handling mult-kind contexts', () => {
416416 } ,
417417 } ;
418418
419+ const multiWithSingleContext = Context . fromLDContext ( {
420+ kind : 'multi' ,
421+ user : {
422+ key : 'abc' ,
423+ name : 'alphabet' ,
424+ letters : [ 'a' , 'b' , 'c' ] ,
425+ order : 3 ,
426+ object : {
427+ a : 'a' ,
428+ b : 'b' ,
429+ } ,
430+ _meta : {
431+ privateAttributes : [ 'letters' , '/object/b' ] ,
432+ } ,
433+ } ,
434+ } ) ;
435+
419436 it ( 'it should remove attributes from all contexts when all attributes are private.' , ( ) => {
420437 const uf = new ContextFilter ( true , [ ] ) ;
421438 expect ( uf . filter ( orgAndUserContext ) ) . toEqual ( orgAndUserContextAllPrivate ) ;
@@ -430,4 +447,20 @@ describe('when handling mult-kind contexts', () => {
430447 const uf = new ContextFilter ( false , [ new AttributeReference ( 'name' , true ) ] ) ;
431448 expect ( uf . filter ( orgAndUserContext ) ) . toEqual ( orgAndUserGlobalNamePrivate ) ;
432449 } ) ;
450+
451+ it ( 'should produce event with valid single context' , ( ) => {
452+ const uf = new ContextFilter ( false , [ ] ) ;
453+ expect ( uf . filter ( multiWithSingleContext ) ) . toEqual ( {
454+ kind : 'user' ,
455+ _meta : {
456+ redactedAttributes : [ '/object/b' , 'letters' ] ,
457+ } ,
458+ key : 'abc' ,
459+ name : 'alphabet' ,
460+ object : {
461+ a : 'a' ,
462+ } ,
463+ order : 3 ,
464+ } ) ;
465+ } ) ;
433466} ) ;
Original file line number Diff line number Diff line change @@ -265,7 +265,7 @@ export default class Context {
265265 if ( kinds . length === 1 ) {
266266 const kind = kinds [ 0 ] ;
267267 const created = new Context ( true , kind ) ;
268- created . context = contexts [ kind ] ;
268+ created . context = { ... contexts [ kind ] , kind } ;
269269 created . privateAttributeReferences = privateAttributes ;
270270 created . isUser = kind === 'user' ;
271271 return created ;
You can’t perform that action at this time.
0 commit comments