@@ -260,7 +260,7 @@ describe('AccountSection', () => {
260260
261261 expect ( getByText ( 'Expires in ~2 days' ) ) . toBeInTheDocument ( ) ;
262262 expect ( getByText ( / O r d e r s w i l l n o l o n g e r b e m a t c h e d / ) ) . toBeInTheDocument ( ) ;
263- expect ( getByText ( 'Close Account ' ) ) . toBeInTheDocument ( ) ;
263+ expect ( getByText ( 'Close' ) ) . toBeInTheDocument ( ) ;
264264 } ) ;
265265
266266 it ( 'should close an expired account' , async ( ) => {
@@ -271,8 +271,8 @@ describe('AccountSection', () => {
271271
272272 const { getByText, changeInput } = render ( ) ;
273273
274- expect ( getByText ( 'Close Account ' ) ) . toBeInTheDocument ( ) ;
275- fireEvent . click ( getByText ( 'Close Account ' ) ) ;
274+ expect ( getByText ( 'Close' ) ) . toBeInTheDocument ( ) ;
275+ fireEvent . click ( getByText ( 'Close' ) ) ;
276276
277277 changeInput ( 'Destination Address' , 'abc123' ) ;
278278 changeInput ( 'Fee' , '10' ) ;
@@ -284,9 +284,6 @@ describe('AccountSection', () => {
284284
285285 // capture the request that is sent to the API
286286 let req : POOL . CloseAccountRequest . AsObject ;
287- // injectIntoGrpcUnary((desc, props) => {
288- // req = props.request.toObject() as any;
289- // }, 'CloseAccount');
290287 grpcMock . unary . mockImplementation ( ( desc , props ) => {
291288 if ( desc . methodName === 'CloseAccount' ) {
292289 req = props . request . toObject ( ) as any ;
@@ -314,4 +311,57 @@ describe('AccountSection', () => {
314311 expect ( req ! . outputWithFee ?. feeRateSatPerKw ) . toBe ( 2500 ) ;
315312 expect ( req ! . outputWithFee ?. address ) . toBe ( 'abc123' ) ;
316313 } ) ;
314+
315+ it ( 'should renew an expired account' , async ( ) => {
316+ // set the account to expire in less than 3 days
317+ runInAction ( ( ) => {
318+ const currHeight = store . nodeStore . blockHeight ;
319+ store . accountStore . activeAccount . expirationHeight = currHeight + 144 * 2 ;
320+ } ) ;
321+
322+ const { getByText, changeInput } = render ( ) ;
323+
324+ expect ( getByText ( 'Renew Account' ) ) . toBeInTheDocument ( ) ;
325+ fireEvent . click ( getByText ( 'Renew Account' ) ) ;
326+
327+ changeInput ( 'New Expiration' , '2016' ) ;
328+ changeInput ( 'Fee Rate' , '125' ) ;
329+ fireEvent . click ( getByText ( 'Renew' ) ) ;
330+
331+ // check confirmation values
332+ expect ( getByText ( '288 blocks' ) ) . toBeInTheDocument ( ) ;
333+ expect ( getByText ( '~2 days' ) ) . toBeInTheDocument ( ) ;
334+ expect ( getByText ( '2016 blocks' ) ) . toBeInTheDocument ( ) ;
335+ expect ( getByText ( '~2 weeks' ) ) . toBeInTheDocument ( ) ;
336+ expect ( getByText ( '125 sats/vByte' ) ) . toBeInTheDocument ( ) ;
337+
338+ // capture the request that is sent to the API
339+ let req : POOL . RenewAccountRequest . AsObject ;
340+ grpcMock . unary . mockImplementation ( ( desc , props ) => {
341+ if ( desc . methodName === 'RenewAccount' ) {
342+ req = props . request . toObject ( ) as any ;
343+ }
344+ const path = `${ desc . service . serviceName } .${ desc . methodName } ` ;
345+ const toObject = ( ) => sampleApiResponses [ path ] ;
346+ // return a response by calling the onEnd function
347+ props . onEnd ( {
348+ status : grpc . Code . OK ,
349+ // the message returned should have a toObject function
350+ message : { toObject } as any ,
351+ } as any ) ;
352+ return undefined as any ;
353+ } ) ;
354+
355+ fireEvent . click ( getByText ( 'Confirm' ) ) ;
356+
357+ // wait until the account view is displayed
358+ await waitFor ( ( ) => {
359+ expect ( req ) . toBeDefined ( ) ;
360+ expect ( getByText ( 'Account' ) ) . toBeInTheDocument ( ) ;
361+ } ) ;
362+
363+ expect ( req ! . accountKey ) . toBe ( b64 ( store . accountStore . activeAccount . traderKey ) ) ;
364+ expect ( req ! . feeRateSatPerKw ) . toBe ( 31250 ) ;
365+ expect ( req ! . relativeExpiry ) . toBe ( 2016 ) ;
366+ } ) ;
317367} ) ;
0 commit comments