@@ -239,9 +239,12 @@ function createMultiplatformTestCase(
239239 t . it ( `${ platform } should handle session upgrades` , async ( ) => {
240240 // Get mocks from the module mock
241241 const multichainModule = await import ( '@metamask/multichain-api-client' ) ;
242+ const mockTransport = ( multichainModule as any ) . __mockTransport ;
242243 const mockMultichainClient = ( multichainModule as any ) . __mockMultichainClient ;
243244
244- // Mock no session scenario
245+
246+ mockTransport . isConnected = false ;
247+ mockTransport . connect . mockResolvedValue ( true ) ;
245248 mockMultichainClient . getSession . mockResolvedValue ( mockSessionData ) ;
246249
247250 sdk = await createSDK ( options ) ;
@@ -250,18 +253,36 @@ function createMultiplatformTestCase(
250253 t . expect ( sdk . isInitialized ) . toBe ( true ) ;
251254 t . expect ( sdk . session ) . not . toBeUndefined ( ) ;
252255
253-
254256 const mockedSessionUpgradeData : SessionData = {
257+ ...mockSessionData ,
255258 sessionScopes : {
256259 'eip155:1' : {
257260 methods : [ 'eth_sendTransaction' , 'eth_accounts' ] ,
258261 notifications : [ 'accountsChanged' , 'chainChanged' ] ,
259262 accounts : [ 'eip155:1:0x1234567890abcdef1234567890abcdef12345678' ] ,
260263 } ,
261264 } ,
262- expiry : new Date ( Date . now ( ) + 3600000 ) . toISOString ( ) ,
263265 } ;
264266
267+ const scopes = [ 'eip155:137' ] as Scope [ ] ;
268+ const caipAccountIds = [ 'eip155:137:0x1234567890abcdef1234567890abcdef12345678' ] as any ;
269+ const result = await sdk . connect ( scopes , caipAccountIds ) ;
270+
271+ t . expect ( mockTransport . connect ) . toHaveBeenCalled ( ) ;
272+ t . expect ( mockMultichainClient . getSession ) . toHaveBeenCalled ( ) ;
273+ t . expect ( mockMultichainClient . revokeSession ) . toHaveBeenCalled ( ) ;
274+ t . expect ( mockMultichainClient . createSession ) . toHaveBeenCalledWith ( {
275+ optionalScopes : {
276+ 'eip155:137' : {
277+ methods : [ ] ,
278+ notifications : [ ] ,
279+ accounts : [ '0x1234567890abcdef1234567890abcdef12345678' ] ,
280+ } ,
281+ } ,
282+ } ) ;
283+ t . expect ( result ) . toEqual ( mockedSessionUpgradeData ) ;
284+
285+
265286 } )
266287
267288 t . it ( `${ platform } should handle session retrieval when no session exists` , async ( ) => {
@@ -345,6 +366,7 @@ function createMultiplatformTestCase(
345366
346367 t . expect ( mockTransport . connect ) . toHaveBeenCalled ( ) ;
347368 t . expect ( mockMultichainClient . getSession ) . toHaveBeenCalled ( ) ;
369+ t . expect ( mockMultichainClient . revokeSession ) . not . toHaveBeenCalled ( ) ;
348370 t . expect ( mockMultichainClient . createSession ) . toHaveBeenCalledWith ( {
349371 optionalScopes : {
350372 'eip155:1' : {
0 commit comments