@@ -330,7 +330,7 @@ describe('given a multi context', () => {
330330describe ( 'given mock crypto' , ( ) => {
331331 const crypto = setupCrypto ( ) ;
332332
333- it ( 'two equal contexts hash the same' , async ( ) => {
333+ it ( 'hashes two equal contexts the same' , async ( ) => {
334334 const a = Context . fromLDContext ( {
335335 kind : 'multi' ,
336336 org : {
@@ -373,7 +373,7 @@ describe('given mock crypto', () => {
373373 expect ( await a . hash ( crypto ) ) . toEqual ( await b . hash ( crypto ) ) ;
374374 } ) ;
375375
376- it ( 'legacy and non-legacy equivalent contexts hash the same' , async ( ) => {
376+ it ( 'hashes legacy and non-legacy equivalent contexts the same' , async ( ) => {
377377 const legacy = Context . fromLDContext ( {
378378 key : 'testKey' ,
379379 name : 'testName' ,
@@ -397,7 +397,7 @@ describe('given mock crypto', () => {
397397 expect ( await legacy . hash ( crypto ) ) . toEqual ( await nonLegacy . hash ( crypto ) ) ;
398398 } ) ;
399399
400- it ( 'single context and multi-context with one kind hash the same' , async ( ) => {
400+ it ( 'hashes single context and multi-context with one kind the same' , async ( ) => {
401401 const single = Context . fromLDContext ( {
402402 kind : 'org' ,
403403 key : 'testKey' ,
@@ -625,6 +625,36 @@ describe('given mock crypto', () => {
625625 expect ( hashA ) . not . toBe ( hashB ) ;
626626 } ) ;
627627
628+ it ( 'hashes _meta in attributes' , async ( ) => {
629+ const a = Context . fromLDContext ( {
630+ kind : 'user' ,
631+ key : 'testKey' ,
632+ nested : {
633+ level1 : {
634+ level2 : {
635+ _meta : { test : 'a' } ,
636+ } ,
637+ } ,
638+ } ,
639+ } ) ;
640+
641+ const b = Context . fromLDContext ( {
642+ kind : 'user' ,
643+ key : 'testKey' ,
644+ nested : {
645+ level1 : {
646+ level2 : {
647+ _meta : { test : 'b' } ,
648+ } ,
649+ } ,
650+ } ,
651+ } ) ;
652+
653+ const hashA = await a . hash ( crypto ) ;
654+ const hashB = await b . hash ( crypto ) ;
655+ expect ( hashA ) . not . toBe ( hashB ) ;
656+ } ) ;
657+
628658 it ( 'produces the same value for the given context' , async ( ) => {
629659 // This isn't so much a test as it is a detection of change.
630660 // If this test failed, and you didn't expect it, then you probably need to make sure your
@@ -654,13 +684,14 @@ describe('given mock crypto', () => {
654684 level1 : {
655685 level2 : {
656686 value : 'deep' ,
687+ _meta : { thisShouldBeInTheHash : true } ,
657688 } ,
658689 } ,
659690 } ,
660691 } ,
661692 } ) ;
662693 expect ( await complexContext . hash ( crypto ) ) . toBe (
663- 'customerbirdchickenkeynamenestedorganonymouscatdogkeynamenestedArraya/b/ccatcustom/dog01length201length24301length221testNametestKeylabcalicotruelevel1level2valuedeeptestNametestKeyhenparty parrot' ,
694+ 'customerbirdchickenkeynamenestedorganonymouscatdogkeynamenestedArraya/b/ccatcustom/dog01length201length24301length221testNametestKeylabcalicotruelevel1level2_metavaluedeepthisShouldBeInTheHashtruetestNametestKeyhenparty parrot' ,
664695 ) ;
665696 } ) ;
666697} ) ;
0 commit comments