@@ -51,6 +51,15 @@ describe('W3mDepositFromExchangeView', () => {
5151 vi . clearAllMocks ( )
5252 } )
5353
54+ it ( 'should reset state on constructor' , async ( ) => {
55+ vi . spyOn ( ExchangeController , 'reset' )
56+ const element : W3mDepositFromExchangeView = await fixture (
57+ html `< w3m-deposit-from-exchange-view > </ w3m-deposit-from-exchange-view > `
58+ )
59+ await elementUpdated ( element )
60+ expect ( ExchangeController . reset ) . toHaveBeenCalled ( )
61+ } )
62+
5463 it ( 'should fetch and set default payment asset on first update' , async ( ) => {
5564 vi . spyOn ( ChainController , 'state' , 'get' ) . mockReturnValue ( {
5665 ...ChainController . state ,
@@ -113,12 +122,6 @@ describe('W3mDepositFromExchangeView', () => {
113122 }
114123
115124 // Seed controller state for exchanges and amount
116- ExchangeController . state . exchanges = [
117- { id : 'ex1' , imageUrl : 'https://img1' , name : 'Exchange One' } ,
118- { id : 'ex2' , imageUrl : 'https://img2' , name : 'Exchange Two' }
119- ] as any
120- ExchangeController . state . amount = 0
121- ExchangeController . state . paymentAsset = mockPaymentAsset
122125
123126 // Avoid side effects on firstUpdated
124127 vi . spyOn ( ExchangeController , 'getAssetsForNetwork' ) . mockResolvedValue ( [ mockPaymentAsset ] )
@@ -127,6 +130,12 @@ describe('W3mDepositFromExchangeView', () => {
127130 const element : W3mDepositFromExchangeView = await fixture (
128131 html `< w3m-deposit-from-exchange-view > </ w3m-deposit-from-exchange-view > `
129132 )
133+ ExchangeController . state . exchanges = [
134+ { id : 'ex1' , imageUrl : 'https://img1' , name : 'Exchange One' } ,
135+ { id : 'ex2' , imageUrl : 'https://img2' , name : 'Exchange Two' }
136+ ] as any
137+ ExchangeController . state . amount = 0
138+ ExchangeController . state . paymentAsset = mockPaymentAsset
130139 await elementUpdated ( element )
131140
132141 // Asset token button should reflect payment asset symbol
@@ -229,7 +238,7 @@ describe('W3mDepositFromExchangeView', () => {
229238
230239 element . disconnectedCallback ( )
231240
232- expect ( resetSpy ) . not . toHaveBeenCalled ( )
241+ expect ( resetSpy ) . toHaveBeenCalledOnce ( )
233242 } )
234243
235244 it ( 'resets when transaction succeeds' , async ( ) => {
0 commit comments