import { testing , PartialApplicationConfig } from 'lisk-framework' ; import axios from 'axios' ; import { callNetwork , getURL } from './utils/application' ; import { HTTPAPIPlugin } from '../../src/http_api_plugin' ; describe ( 'Forging info endpoint' , ( ) => { let appEnv ; let forgingStatusData ; const label = 'forging_info_http_functional' ; beforeAll ( async ( ) => { const rootPath = '~/.lisk/http-plugin' ; const config = { rootPath , label , } as PartialApplicationConfig ; appEnv = testing . createDefaultApplicationEnv ( { config , plugins : [ HTTPAPIPlugin ] , } ) ; await appEnv . startApplication ( ) ; forgingStatusData = await appEnv . ipcClient . invoke ( 'app:getForgingStatus' ) ; } ) ; afterAll ( async ( ) => { jest . spyOn ( process , 'exit' ) . mockImplementation ( ( ( ) => { } ) as never ) ; await appEnv . stopApplication ( ) ; } ) ; describe ( '/api/forging/info' , ( ) => { describe ( '200 - Success' , ( ) => { it ( 'should respond with all the forgers info' , async ( ) => { const { response , status } = await callNetwork ( axios . get ( getURL ( '/api/forging/info' ) ) ) ; expect ( response . data ) . toHaveLength ( 103 ) ; expect ( response . data ) . toEqual ( forgingStatusData ) ; expect ( response . meta ) . toEqual ( { count : 103 , } ) ; expect ( status ) . toBe ( 200 ) ; } ) ; } ) ; } ) ; } ) ;