11import  {  EventEnvelope  }  from  '@sentry/types' ; 
2+ import  {  TextEncoder  }  from  'util' ; 
23
34import  {  addItemToEnvelope ,  createEnvelope ,  forEachEnvelopeItem ,  serializeEnvelope  }  from  '../src/envelope' ; 
45import  {  parseEnvelope  }  from  './testutils' ; 
@@ -20,15 +21,15 @@ describe('envelope', () => {
2021  describe ( 'serializeEnvelope()' ,  ( )  =>  { 
2122    it ( 'serializes an envelope' ,  ( )  =>  { 
2223      const  env  =  createEnvelope < EventEnvelope > ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ,  [ ] ) ; 
23-       const  [ headers ]  =  parseEnvelope ( serializeEnvelope ( env ) ) ; 
24+       const  [ headers ]  =  parseEnvelope ( serializeEnvelope ( env ,   new   TextEncoder ( ) ) ) ; 
2425      expect ( headers ) . toEqual ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ) ; 
2526    } ) ; 
2627  } ) ; 
2728
2829  describe ( 'addItemToEnvelope()' ,  ( )  =>  { 
2930    it ( 'adds an item to an envelope' ,  ( )  =>  { 
3031      const  env  =  createEnvelope < EventEnvelope > ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ,  [ ] ) ; 
31-       let  [ envHeaders ,  items ]  =  parseEnvelope ( serializeEnvelope ( env ) ) ; 
32+       let  [ envHeaders ,  items ]  =  parseEnvelope ( serializeEnvelope ( env ,   new   TextEncoder ( ) ) ) ; 
3233      expect ( items ) . toHaveLength ( 0 ) ; 
3334      expect ( envHeaders ) . toEqual ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ) ; 
3435
@@ -37,7 +38,7 @@ describe('envelope', () => {
3738        {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2'  } , 
3839      ] ) ; 
3940
40-       [ envHeaders ,  items ]  =  parseEnvelope ( serializeEnvelope ( newEnv ) ) ; 
41+       [ envHeaders ,  items ]  =  parseEnvelope ( serializeEnvelope ( newEnv ,   new   TextEncoder ( ) ) ) ; 
4142      expect ( envHeaders ) . toEqual ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ) ; 
4243      expect ( items ) . toHaveLength ( 1 ) ; 
4344      expect ( items [ 0 ] ) . toEqual ( [ {  type : 'event'  } ,  {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2'  } ] ) ; 
@@ -66,7 +67,7 @@ describe('envelope', () => {
6667        iteration  =  iteration  +  1 ; 
6768      } ) ; 
6869
69-       const  [ parsedHeaders ,  parsedItems ]  =  parseEnvelope ( serializeEnvelope ( env ) ) ; 
70+       const  [ parsedHeaders ,  parsedItems ]  =  parseEnvelope ( serializeEnvelope ( env ,   new   TextEncoder ( ) ) ) ; 
7071      expect ( parsedHeaders ) . toEqual ( {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2' ,  sent_at : '123'  } ) ; 
7172      expect ( parsedItems ) . toHaveLength ( 3 ) ; 
7273      expect ( items [ 0 ] ) . toEqual ( [ {  type : 'event'  } ,  {  event_id : 'aa3ff046696b4bc6b609ce6d28fde9e2'  } ] ) ; 
0 commit comments