@@ -29,6 +29,10 @@ describe('BridgeController', function () {
29
29
nock ( BRIDGE_API_BASE_URL )
30
30
. get ( '/getAllFeatureFlags' )
31
31
. reply ( 200 , {
32
+ 'extension-config' : {
33
+ refreshRate : 3 ,
34
+ maxRefreshCount : 1 ,
35
+ } ,
32
36
'extension-support' : true ,
33
37
'src-network-allowlist' : [ 10 , 534352 ] ,
34
38
'dest-network-allowlist' : [ 137 , 42161 ] ,
@@ -55,6 +59,7 @@ describe('BridgeController', function () {
55
59
symbol : 'ABC' ,
56
60
} ,
57
61
] ) ;
62
+ bridgeController . resetState ( ) ;
58
63
} ) ;
59
64
60
65
it ( 'constructor should setup correctly' , function ( ) {
@@ -66,6 +71,10 @@ describe('BridgeController', function () {
66
71
extensionSupport : true ,
67
72
destNetworkAllowlist : [ CHAIN_IDS . POLYGON , CHAIN_IDS . ARBITRUM ] ,
68
73
srcNetworkAllowlist : [ CHAIN_IDS . OPTIMISM , CHAIN_IDS . SCROLL ] ,
74
+ extensionConfig : {
75
+ maxRefreshCount : 1 ,
76
+ refreshRate : 3 ,
77
+ } ,
69
78
} ;
70
79
expect ( bridgeController . state ) . toStrictEqual ( EMPTY_INIT_STATE ) ;
71
80
@@ -94,6 +103,11 @@ describe('BridgeController', function () {
94
103
expect ( bridgeController . state . bridgeState . destTopAssets ) . toStrictEqual ( [
95
104
{ address : '0x1f9840a85d5af5bf1d1762f925bdaddc4201f984' , symbol : 'ABC' } ,
96
105
] ) ;
106
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
107
+ slippage : 0.5 ,
108
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
109
+ walletAddress : undefined ,
110
+ } ) ;
97
111
} ) ;
98
112
99
113
it ( 'selectSrcNetwork should set the bridge src tokens and top assets' , async function ( ) {
@@ -118,5 +132,76 @@ describe('BridgeController', function () {
118
132
symbol : 'ABC' ,
119
133
} ,
120
134
] ) ;
135
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
136
+ slippage : 0.5 ,
137
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
138
+ walletAddress : undefined ,
139
+ } ) ;
140
+ } ) ;
141
+
142
+ it ( 'updateBridgeQuoteRequestParams should update the quoteRequest state' , function ( ) {
143
+ bridgeController . updateBridgeQuoteRequestParams ( { srcChainId : 1 } ) ;
144
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
145
+ srcChainId : 1 ,
146
+ slippage : 0.5 ,
147
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
148
+ walletAddress : undefined ,
149
+ } ) ;
150
+
151
+ bridgeController . updateBridgeQuoteRequestParams ( { destChainId : 10 } ) ;
152
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
153
+ destChainId : 10 ,
154
+ slippage : 0.5 ,
155
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
156
+ walletAddress : undefined ,
157
+ } ) ;
158
+
159
+ bridgeController . updateBridgeQuoteRequestParams ( { destChainId : undefined } ) ;
160
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
161
+ destChainId : undefined ,
162
+ slippage : 0.5 ,
163
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
164
+ walletAddress : undefined ,
165
+ } ) ;
166
+
167
+ bridgeController . updateBridgeQuoteRequestParams ( {
168
+ srcTokenAddress : undefined ,
169
+ } ) ;
170
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
171
+ slippage : 0.5 ,
172
+ srcTokenAddress : undefined ,
173
+ walletAddress : undefined ,
174
+ } ) ;
175
+
176
+ bridgeController . updateBridgeQuoteRequestParams ( {
177
+ srcTokenAmount : '100000' ,
178
+ destTokenAddress : '0x123' ,
179
+ slippage : 0.5 ,
180
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
181
+ walletAddress : undefined ,
182
+ } ) ;
183
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
184
+ srcTokenAmount : '100000' ,
185
+ destTokenAddress : '0x123' ,
186
+ slippage : 0.5 ,
187
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
188
+ walletAddress : undefined ,
189
+ } ) ;
190
+
191
+ bridgeController . updateBridgeQuoteRequestParams ( {
192
+ srcTokenAddress : '0x2ABC' ,
193
+ } ) ;
194
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
195
+ slippage : 0.5 ,
196
+ srcTokenAddress : '0x2ABC' ,
197
+ walletAddress : undefined ,
198
+ } ) ;
199
+
200
+ bridgeController . resetState ( ) ;
201
+ expect ( bridgeController . state . bridgeState . quoteRequest ) . toStrictEqual ( {
202
+ slippage : 0.5 ,
203
+ srcTokenAddress : '0x0000000000000000000000000000000000000000' ,
204
+ walletAddress : undefined ,
205
+ } ) ;
121
206
} ) ;
122
207
} ) ;
0 commit comments