mirror of https://github.com/lukechilds/polar.git
jamaljsr
5 years ago
committed by
jamaljsr
10 changed files with 235 additions and 59 deletions
@ -0,0 +1,42 @@ |
|||
import React from 'react'; |
|||
import { renderWithProviders } from 'utils/tests'; |
|||
import { BitcoinNode, Status } from 'types'; |
|||
import BitcoindCard from './BitcoindCard'; |
|||
|
|||
describe('StatusTag Component', () => { |
|||
const node: BitcoinNode = { |
|||
id: 1, |
|||
name: 'test btc', |
|||
implementation: 'bitcoind', |
|||
status: Status.Stopped, |
|||
type: 'bitcoin', |
|||
}; |
|||
|
|||
const details = [ |
|||
{ label: 'Block Height', value: '432' }, |
|||
{ label: 'Wallet Balance', value: '54.00000000' }, |
|||
{ label: 'Host', value: '159.65.239.204' }, |
|||
{ label: 'Version', value: 'v0.18.1' }, |
|||
]; |
|||
|
|||
const renderComponent = () => { |
|||
return renderWithProviders(<BitcoindCard node={node} details={details} />); |
|||
}; |
|||
|
|||
it('should render the name', () => { |
|||
const { getByText } = renderComponent(); |
|||
expect(getByText(node.name)).toBeTruthy(); |
|||
}); |
|||
|
|||
it('should render the details', () => { |
|||
const { getByText } = renderComponent(); |
|||
expect(getByText(details[0].label)).toBeTruthy(); |
|||
expect(getByText(details[0].value)).toBeTruthy(); |
|||
expect(getByText(details[1].label)).toBeTruthy(); |
|||
expect(getByText(details[1].value)).toBeTruthy(); |
|||
expect(getByText(details[2].label)).toBeTruthy(); |
|||
expect(getByText(details[2].value)).toBeTruthy(); |
|||
expect(getByText(details[3].label)).toBeTruthy(); |
|||
expect(getByText(details[3].value)).toBeTruthy(); |
|||
}); |
|||
}); |
@ -0,0 +1,46 @@ |
|||
import React from 'react'; |
|||
import { renderWithProviders } from 'utils/tests'; |
|||
import { LightningNode, Status } from 'types'; |
|||
import LndCard from './LndCard'; |
|||
|
|||
describe('StatusTag Component', () => { |
|||
const node: LightningNode = { |
|||
id: 1, |
|||
name: 'test lnd', |
|||
implementation: 'LND', |
|||
status: Status.Stopped, |
|||
type: 'lightning', |
|||
backendName: 'bitcoind-1', |
|||
}; |
|||
|
|||
const details = [ |
|||
{ label: 'PubKey', value: '0245....5fd47' }, |
|||
{ label: 'Host', value: '159.65.239.204' }, |
|||
{ label: 'Synced to Chain', value: 'true' }, |
|||
{ label: 'Chain Node', value: 'bitcoind1' }, |
|||
{ label: 'Version', value: 'v0.7.1' }, |
|||
]; |
|||
|
|||
const renderComponent = () => { |
|||
return renderWithProviders(<LndCard node={node} details={details} />); |
|||
}; |
|||
|
|||
it('should render the name', () => { |
|||
const { getByText } = renderComponent(); |
|||
expect(getByText(node.name)).toBeTruthy(); |
|||
}); |
|||
|
|||
it('should render the details', () => { |
|||
const { getByText } = renderComponent(); |
|||
expect(getByText(details[0].label)).toBeTruthy(); |
|||
expect(getByText(details[0].value)).toBeTruthy(); |
|||
expect(getByText(details[1].label)).toBeTruthy(); |
|||
expect(getByText(details[1].value)).toBeTruthy(); |
|||
expect(getByText(details[2].label)).toBeTruthy(); |
|||
expect(getByText(details[2].value)).toBeTruthy(); |
|||
expect(getByText(details[3].label)).toBeTruthy(); |
|||
expect(getByText(details[3].value)).toBeTruthy(); |
|||
expect(getByText(details[4].label)).toBeTruthy(); |
|||
expect(getByText(details[4].value)).toBeTruthy(); |
|||
}); |
|||
}); |
@ -0,0 +1,45 @@ |
|||
import React from 'react'; |
|||
import { renderWithProviders } from 'utils/tests'; |
|||
import { Status } from 'types'; |
|||
import NetworkActions from './NetworkActions'; |
|||
|
|||
describe('NetworkActions Component', () => { |
|||
const renderComponent = (status: Status) => { |
|||
return renderWithProviders(<NetworkActions status={status} />); |
|||
}; |
|||
|
|||
it('should render the Starting status', () => { |
|||
const { getByText } = renderComponent(Status.Starting); |
|||
expect(getByText('Starting')).toBeTruthy(); |
|||
// button should be loading
|
|||
expect(getByText('Starting').parentElement).toHaveClass('ant-btn-loading'); |
|||
}); |
|||
|
|||
it('should render the Started status', () => { |
|||
const { getByText } = renderComponent(Status.Started); |
|||
expect(getByText('Stop')).toBeTruthy(); |
|||
// button should not be loading
|
|||
expect(getByText('Stop').parentElement).not.toHaveClass('ant-btn-loading'); |
|||
}); |
|||
|
|||
it('should render the Stopping status', () => { |
|||
const { getByText } = renderComponent(Status.Stopping); |
|||
expect(getByText('Stopping')).toBeTruthy(); |
|||
// button should be loading
|
|||
expect(getByText('Stopping').parentElement).toHaveClass('ant-btn-loading'); |
|||
}); |
|||
|
|||
it('should render the Stopped status', () => { |
|||
const { getByText } = renderComponent(Status.Stopped); |
|||
expect(getByText('Start')).toBeTruthy(); |
|||
// button should be loading
|
|||
expect(getByText('Start').parentElement).not.toHaveClass('ant-btn-loading'); |
|||
}); |
|||
|
|||
it('should render the Error status', () => { |
|||
const { getByText } = renderComponent(Status.Error); |
|||
expect(getByText('Restart')).toBeTruthy(); |
|||
// button should be loading
|
|||
expect(getByText('Restart').parentElement).not.toHaveClass('ant-btn-loading'); |
|||
}); |
|||
}); |
@ -0,0 +1,38 @@ |
|||
import React from 'react'; |
|||
import { Route } from 'react-router'; |
|||
import { renderWithProviders, getNetwork } from 'utils/tests'; |
|||
import NetworkView from './NetworkView'; |
|||
|
|||
describe('NetworkView Component', () => { |
|||
const renderComponent = (route = '/network/1') => { |
|||
const initialState = { |
|||
network: { |
|||
networks: [getNetwork(1, 'test network')], |
|||
}, |
|||
}; |
|||
// NetworkView needs to be rendered by the router due to
|
|||
// RouteComponentProps not being easily mockable
|
|||
const cmp = <Route path="/network/:id" component={NetworkView} />; |
|||
return renderWithProviders(cmp, { initialState, route }); |
|||
}; |
|||
|
|||
it('should not render if the network is not found', () => { |
|||
const { queryByText } = renderComponent('/network/99'); |
|||
expect(queryByText('test network')).toBeNull(); |
|||
}); |
|||
|
|||
it('should render the name', () => { |
|||
const { getByText } = renderComponent(); |
|||
expect(getByText('test network')).toBeTruthy(); |
|||
}); |
|||
|
|||
it('should render correct # of LND nodes', () => { |
|||
const { queryAllByText } = renderComponent(); |
|||
expect(queryAllByText(/lnd-\d/)).toHaveLength(2); |
|||
}); |
|||
|
|||
it('should render correct # of bitcoind nodes', () => { |
|||
const { queryAllByText } = renderComponent(); |
|||
expect(queryAllByText(/bitcoind-\d/)).toHaveLength(1); |
|||
}); |
|||
}); |
Loading…
Reference in new issue