@@ -74,6 +74,24 @@ describe('HostRequest round-trip', () => {
7474 expect ( result ) . toEqual ( msg ) ;
7575 } ) ;
7676
77+ it ( 'encodes/decodes attach with compression' , ( ) => {
78+ const msg : HostRequest = { type : 'attach' , paneId : '%1' , cols : 80 , rows : 24 , compression : 'deflate' } ;
79+ const result = roundTrip ( msg ) ;
80+ expect ( result ) . toEqual ( msg ) ;
81+ if ( result . type === 'attach' ) {
82+ expect ( result . compression ) . toBe ( 'deflate' ) ;
83+ }
84+ } ) ;
85+
86+ it ( 'encodes/decodes attach without compression (field absent)' , ( ) => {
87+ const msg : HostRequest = { type : 'attach' , paneId : '%1' , cols : 80 , rows : 24 } ;
88+ const result = roundTrip ( msg ) ;
89+ expect ( result ) . toEqual ( msg ) ;
90+ if ( result . type === 'attach' ) {
91+ expect ( result . compression ) . toBeUndefined ( ) ;
92+ }
93+ } ) ;
94+
7795 it ( 'encodes/decodes detach' , ( ) => {
7896 const msg : HostRequest = { type : 'detach' } ;
7997 const result = roundTrip ( msg ) ;
@@ -166,6 +184,24 @@ describe('HostEvent round-trip', () => {
166184 expect ( result ) . toEqual ( msg ) ;
167185 } ) ;
168186
187+ it ( 'encodes/decodes attached with compression' , ( ) => {
188+ const msg : HostEvent = { type : 'attached' , paneId : '%1' , compression : 'deflate' } ;
189+ const result = roundTrip ( msg ) ;
190+ expect ( result ) . toEqual ( msg ) ;
191+ if ( result . type === 'attached' ) {
192+ expect ( result . compression ) . toBe ( 'deflate' ) ;
193+ }
194+ } ) ;
195+
196+ it ( 'encodes/decodes attached without compression (field absent)' , ( ) => {
197+ const msg : HostEvent = { type : 'attached' , paneId : '%1' } ;
198+ const result = roundTrip ( msg ) ;
199+ expect ( result ) . toEqual ( msg ) ;
200+ if ( result . type === 'attached' ) {
201+ expect ( result . compression ) . toBeUndefined ( ) ;
202+ }
203+ } ) ;
204+
169205 it ( 'encodes/decodes detached' , ( ) => {
170206 const msg : HostEvent = { type : 'detached' } ;
171207 const result = roundTrip ( msg ) ;
@@ -367,6 +403,16 @@ describe('decode structural validation', () => {
367403 expect ( ( ) => decodeMalformed ( { type : 'attach' , paneId : '%1' , cols : 80 , rows : Infinity } ) )
368404 . toThrow ( 'attach: "rows" must be a finite number' ) ;
369405 } ) ;
406+
407+ it ( 'accepts valid compression string' , ( ) => {
408+ expect ( ( ) => decodeMalformed ( { type : 'attach' , paneId : '%1' , cols : 80 , rows : 24 , compression : 'deflate' } ) )
409+ . not . toThrow ( ) ;
410+ } ) ;
411+
412+ it ( 'rejects non-string compression' , ( ) => {
413+ expect ( ( ) => decodeMalformed ( { type : 'attach' , paneId : '%1' , cols : 80 , rows : 24 , compression : 123 } ) )
414+ . toThrow ( 'attach: "compression" must be a string' ) ;
415+ } ) ;
370416 } ) ;
371417
372418 describe ( 'input' , ( ) => {
@@ -441,6 +487,16 @@ describe('decode structural validation', () => {
441487 expect ( ( ) => decodeMalformed ( { type : 'attached' } ) )
442488 . toThrow ( 'attached: "paneId" must be a string' ) ;
443489 } ) ;
490+
491+ it ( 'accepts valid compression string' , ( ) => {
492+ expect ( ( ) => decodeMalformed ( { type : 'attached' , paneId : '%1' , compression : 'deflate' } ) )
493+ . not . toThrow ( ) ;
494+ } ) ;
495+
496+ it ( 'rejects non-string compression' , ( ) => {
497+ expect ( ( ) => decodeMalformed ( { type : 'attached' , paneId : '%1' , compression : 123 } ) )
498+ . toThrow ( 'attached: "compression" must be a string' ) ;
499+ } ) ;
444500 } ) ;
445501
446502 describe ( 'session_ended' , ( ) => {
0 commit comments