@@ -13,78 +13,76 @@ const connector = config.connectors[0]!
1313const contextValue = { foo : 'bar' } as const
1414
1515test ( 'context' , ( ) => {
16- const { connect, connectAsync, context, data, error, variables } = useConnect (
17- {
18- mutation : {
19- onMutate ( variables ) {
20- expectTypeOf ( variables ) . toEqualTypeOf < {
21- chainId ?: number | undefined
22- connector : Connector | CreateConnectorFn
23- withCapabilities ?: boolean | undefined
24- } > ( )
25- return contextValue
26- } ,
27- onError ( error , variables , context ) {
28- expectTypeOf ( variables ) . toEqualTypeOf < {
29- chainId ?: number | undefined
30- connector : Connector | CreateConnectorFn
31- withCapabilities ?: boolean | undefined
32- } > ( )
33- expectTypeOf ( error ) . toEqualTypeOf < ConnectErrorType > ( )
34- expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
35- } ,
36- onSuccess ( data , variables , context ) {
37- expectTypeOf ( variables ) . toEqualTypeOf < {
38- chainId ?: number | undefined
39- connector : Connector | CreateConnectorFn
40- withCapabilities ?: boolean | undefined
41- } > ( )
42- expectTypeOf ( data ) . toEqualTypeOf < {
43- accounts :
44- | readonly [ Address , ...Address [ ] ]
45- | readonly [
46- { address : Address ; capabilities : Record < string , unknown > } ,
47- ...{
48- address : Address
49- capabilities : Record < string , unknown >
50- } [ ] ,
51- ]
52- chainId : number
53- } > ( )
54- expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue > ( )
55- } ,
56- onSettled ( data , error , variables , context ) {
57- expectTypeOf ( data ) . toEqualTypeOf <
58- | {
59- accounts :
60- | readonly [ Address , ...Address [ ] ]
61- | readonly [
62- {
63- address : Address
64- capabilities : Record < string , unknown >
65- } ,
66- ...{
67- address : Address
68- capabilities : Record < string , unknown >
69- } [ ] ,
70- ]
71- chainId : number
72- }
73- | undefined
74- > ( )
75- expectTypeOf ( error ) . toEqualTypeOf < ConnectErrorType | null > ( )
76- expectTypeOf ( variables ) . toEqualTypeOf < {
77- chainId ?: number | undefined
78- connector : Connector | CreateConnectorFn
79- withCapabilities ?: boolean | undefined
80- } > ( )
81- expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
82- } ,
16+ const connect = useConnect ( {
17+ mutation : {
18+ onMutate ( variables ) {
19+ expectTypeOf ( variables ) . toEqualTypeOf < {
20+ chainId ?: number | undefined
21+ connector : Connector | CreateConnectorFn
22+ withCapabilities ?: boolean | undefined
23+ } > ( )
24+ return contextValue
25+ } ,
26+ onError ( error , variables , context ) {
27+ expectTypeOf ( variables ) . toEqualTypeOf < {
28+ chainId ?: number | undefined
29+ connector : Connector | CreateConnectorFn
30+ withCapabilities ?: boolean | undefined
31+ } > ( )
32+ expectTypeOf ( error ) . toEqualTypeOf < ConnectErrorType > ( )
33+ expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
34+ } ,
35+ onSuccess ( data , variables , context ) {
36+ expectTypeOf ( variables ) . toEqualTypeOf < {
37+ chainId ?: number | undefined
38+ connector : Connector | CreateConnectorFn
39+ withCapabilities ?: boolean | undefined
40+ } > ( )
41+ expectTypeOf ( data ) . toEqualTypeOf < {
42+ accounts :
43+ | readonly [ Address , ...Address [ ] ]
44+ | readonly [
45+ { address : Address ; capabilities : Record < string , unknown > } ,
46+ ...{
47+ address : Address
48+ capabilities : Record < string , unknown >
49+ } [ ] ,
50+ ]
51+ chainId : number
52+ } > ( )
53+ expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue > ( )
54+ } ,
55+ onSettled ( data , error , variables , context ) {
56+ expectTypeOf ( data ) . toEqualTypeOf <
57+ | {
58+ accounts :
59+ | readonly [ Address , ...Address [ ] ]
60+ | readonly [
61+ {
62+ address : Address
63+ capabilities : Record < string , unknown >
64+ } ,
65+ ...{
66+ address : Address
67+ capabilities : Record < string , unknown >
68+ } [ ] ,
69+ ]
70+ chainId : number
71+ }
72+ | undefined
73+ > ( )
74+ expectTypeOf ( error ) . toEqualTypeOf < ConnectErrorType | null > ( )
75+ expectTypeOf ( variables ) . toEqualTypeOf < {
76+ chainId ?: number | undefined
77+ connector : Connector | CreateConnectorFn
78+ withCapabilities ?: boolean | undefined
79+ } > ( )
80+ expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
8381 } ,
8482 } ,
85- )
83+ } )
8684
87- expectTypeOf ( data ) . toEqualTypeOf <
85+ expectTypeOf ( connect . data ) . toEqualTypeOf <
8886 | {
8987 accounts :
9088 | readonly [ Address , ...Address [ ] ]
@@ -96,17 +94,17 @@ test('context', () => {
9694 }
9795 | undefined
9896 > ( )
99- expectTypeOf ( error ) . toEqualTypeOf < ConnectErrorType | null > ( )
100- expectTypeOf ( variables ) . toMatchTypeOf <
97+ expectTypeOf ( connect . error ) . toEqualTypeOf < ConnectErrorType | null > ( )
98+ expectTypeOf ( connect . variables ) . toMatchTypeOf <
10199 | {
102100 chainId ?: number | undefined
103101 connector : CreateConnectorFn | Connector
104102 }
105103 | undefined
106104 > ( )
107- expectTypeOf ( context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
105+ expectTypeOf ( connect . context ) . toEqualTypeOf < typeof contextValue | undefined > ( )
108106
109- connect (
107+ connect . mutate (
110108 {
111109 connector,
112110 foo : 'bar' ,
@@ -155,7 +153,7 @@ test('context', () => {
155153 } ,
156154 )
157155
158- connect (
156+ connect . mutate (
159157 {
160158 connector,
161159 foo : 'bar' ,
@@ -207,7 +205,7 @@ test('context', () => {
207205 )
208206
209207 ; ( async ( ) => {
210- const res = await connectAsync ( {
208+ const res = await connect . mutateAsync ( {
211209 connector,
212210 foo : 'bar' ,
213211 withCapabilities : true ,
0 commit comments