@@ -29,8 +29,8 @@ describe("useAutoConnectCore", () => {
2929 adaptedAccount : TEST_ACCOUNT_A ,
3030 client : TEST_CLIENT ,
3131 chain : ethereum ,
32- onDisconnect : ( ) => { } ,
33- switchChain : ( ) => { } ,
32+ onDisconnect : ( ) => { } ,
33+ switchChain : ( ) => { } ,
3434 } ) ;
3535
3636 expect (
@@ -49,7 +49,7 @@ describe("useAutoConnectCore", () => {
4949 onDisconnect : ( ) => {
5050 console . warn ( id ) ;
5151 } ,
52- switchChain : ( ) => { } ,
52+ switchChain : ( ) => { } ,
5353 } ) ,
5454 manager,
5555 } ) ,
@@ -63,8 +63,8 @@ describe("useAutoConnectCore", () => {
6363 adaptedAccount : TEST_ACCOUNT_A ,
6464 client : TEST_CLIENT ,
6565 chain : ethereum ,
66- onDisconnect : ( ) => { } ,
67- switchChain : ( ) => { } ,
66+ onDisconnect : ( ) => { } ,
67+ switchChain : ( ) => { } ,
6868 } ) ;
6969
7070 expect (
@@ -83,74 +83,21 @@ describe("useAutoConnectCore", () => {
8383 onDisconnect : ( ) => {
8484 console . warn ( id ) ;
8585 } ,
86- switchChain : ( ) => { } ,
86+ switchChain : ( ) => { } ,
8787 } ) ,
8888 manager,
8989 } ) ,
9090 ) . toBe ( false ) ;
9191 } ) ;
9292
93- it ( "should call onTimeout on ... timeout" , async ( ) => {
94- vi . mocked ( getUrlToken ) . mockReturnValue ( { } ) ;
95-
96- const wallet = createWalletAdapter ( {
97- adaptedAccount : TEST_ACCOUNT_A ,
98- client : TEST_CLIENT ,
99- chain : ethereum ,
100- onDisconnect : ( ) => { } ,
101- switchChain : ( ) => { } ,
102- } ) ;
103- mockStorage . setItem ( "thirdweb:active-wallet-id" , wallet . id ) ;
104- const warnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
105- const infoSpy = vi . spyOn ( console , "info" ) . mockImplementation ( ( ) => { } ) ;
106- // Purposefully mock the wallet.autoConnect method to test the timeout logic
107- wallet . autoConnect = ( ) =>
108- new Promise ( ( resolve ) => {
109- setTimeout ( ( ) => {
110- // @ts -ignore Mock purpose
111- resolve ( "Connection successful" ) ;
112- } , 2100 ) ;
113- } ) ;
114-
115- await autoConnectCore ( {
116- force : true ,
117- storage : mockStorage ,
118- props : {
119- wallets : [ wallet ] ,
120- client : TEST_CLIENT ,
121- onTimeout : ( ) => { } ,
122- timeout : 0 ,
123- } ,
124- createWalletFn : ( id : WalletId ) =>
125- createWalletAdapter ( {
126- adaptedAccount : TEST_ACCOUNT_A ,
127- client : TEST_CLIENT ,
128- chain : ethereum ,
129- onDisconnect : ( ) => {
130- console . warn ( id ) ;
131- } ,
132- switchChain : ( ) => { } ,
133- } ) ,
134- manager,
135- } ) ;
136-
137- expect ( warnSpy ) . toHaveBeenCalled ( ) ;
138- expect ( warnSpy ) . toHaveBeenCalledWith (
139- "AutoConnect timeout: 0ms limit exceeded." ,
140- ) ;
141- expect ( infoSpy ) . toHaveBeenCalled ( ) ;
142- expect ( infoSpy ) . toHaveBeenCalledWith ( "TIMEOUTTED" ) ;
143- warnSpy . mockRestore ( ) ;
144- } ) ;
145-
14693 it ( "should handle auth cookie storage correctly" , async ( ) => {
14794 const mockAuthCookie = "mock-auth-cookie" ;
14895 const wallet = createWalletAdapter ( {
14996 adaptedAccount : TEST_ACCOUNT_A ,
15097 client : TEST_CLIENT ,
15198 chain : ethereum ,
152- onDisconnect : ( ) => { } ,
153- switchChain : ( ) => { } ,
99+ onDisconnect : ( ) => { } ,
100+ switchChain : ( ) => { } ,
154101 } ) ;
155102 vi . mocked ( getUrlToken ) . mockReturnValue ( {
156103 authCookie : mockAuthCookie ,
@@ -179,8 +126,8 @@ describe("useAutoConnectCore", () => {
179126 adaptedAccount : TEST_ACCOUNT_A ,
180127 client : TEST_CLIENT ,
181128 chain : ethereum ,
182- onDisconnect : ( ) => { } ,
183- switchChain : ( ) => { } ,
129+ onDisconnect : ( ) => { } ,
130+ switchChain : ( ) => { } ,
184131 } ) ;
185132
186133 mockStorage . setItem ( "thirdweb:active-wallet-id" , wallet1 . id ) ;
@@ -192,7 +139,7 @@ describe("useAutoConnectCore", () => {
192139 const addConnectedWalletSpy = vi
193140 . spyOn ( manager , "connect" )
194141 . mockRejectedValueOnce ( new Error ( "Connection failed" ) ) ;
195- const warnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
142+ const warnSpy = vi . spyOn ( console , "warn" ) . mockImplementation ( ( ) => { } ) ;
196143
197144 await autoConnectCore ( {
198145 force : true ,
@@ -218,16 +165,16 @@ describe("useAutoConnectCore", () => {
218165 adaptedAccount : TEST_ACCOUNT_A ,
219166 client : TEST_CLIENT ,
220167 chain : ethereum ,
221- onDisconnect : ( ) => { } ,
222- switchChain : ( ) => { } ,
168+ onDisconnect : ( ) => { } ,
169+ switchChain : ( ) => { } ,
223170 } ) ;
224171
225172 const wallet2 = createWalletAdapter ( {
226173 adaptedAccount : { ...TEST_ACCOUNT_A , address : "0x123" } ,
227174 client : TEST_CLIENT ,
228175 chain : ethereum ,
229- onDisconnect : ( ) => { } ,
230- switchChain : ( ) => { } ,
176+ onDisconnect : ( ) => { } ,
177+ switchChain : ( ) => { } ,
231178 } ) ;
232179 wallet2 . id = "io.metamask" as unknown as "adapter" ;
233180
@@ -259,8 +206,8 @@ describe("useAutoConnectCore", () => {
259206 adaptedAccount : TEST_ACCOUNT_A ,
260207 client : TEST_CLIENT ,
261208 chain : ethereum ,
262- onDisconnect : ( ) => { } ,
263- switchChain : ( ) => { } ,
209+ onDisconnect : ( ) => { } ,
210+ switchChain : ( ) => { } ,
264211 } ) ;
265212
266213 vi . mocked ( getUrlToken ) . mockReturnValue ( { } ) ;
@@ -293,8 +240,8 @@ describe("useAutoConnectCore", () => {
293240 adaptedAccount : TEST_ACCOUNT_A ,
294241 client : TEST_CLIENT ,
295242 chain : ethereum ,
296- onDisconnect : ( ) => { } ,
297- switchChain : ( ) => { } ,
243+ onDisconnect : ( ) => { } ,
244+ switchChain : ( ) => { } ,
298245 } ) ;
299246
300247 vi . mocked ( getUrlToken ) . mockReturnValue ( { } ) ;
@@ -323,8 +270,8 @@ describe("useAutoConnectCore", () => {
323270 adaptedAccount : TEST_ACCOUNT_A ,
324271 client : TEST_CLIENT ,
325272 chain : ethereum ,
326- onDisconnect : ( ) => { } ,
327- switchChain : ( ) => { } ,
273+ onDisconnect : ( ) => { } ,
274+ switchChain : ( ) => { } ,
328275 } ) ;
329276 vi . mocked ( getUrlToken ) . mockReturnValue ( {
330277 authProvider : "email" ,
@@ -357,8 +304,8 @@ describe("useAutoConnectCore", () => {
357304 adaptedAccount : TEST_ACCOUNT_A ,
358305 client : TEST_CLIENT ,
359306 chain : ethereum ,
360- onDisconnect : ( ) => { } ,
361- switchChain : ( ) => { } ,
307+ onDisconnect : ( ) => { } ,
308+ switchChain : ( ) => { } ,
362309 } ) ;
363310
364311 mockStorage . setItem ( "thirdweb:active-wallet-id" , wallet . id ) ;
@@ -394,8 +341,8 @@ describe("handleWalletConnection", () => {
394341 adaptedAccount : TEST_ACCOUNT_A ,
395342 client : TEST_CLIENT ,
396343 chain : ethereum ,
397- onDisconnect : ( ) => { } ,
398- switchChain : ( ) => { } ,
344+ onDisconnect : ( ) => { } ,
345+ switchChain : ( ) => { } ,
399346 } ) ;
400347 it ( "should return the correct result" , async ( ) => {
401348 const result = await handleWalletConnection ( {
0 commit comments