test(status-pill): add StatusPill tests

This commit is contained in:
George Lima 2019-01-23 12:40:18 -03:00
parent e918f319ba
commit 8fc737081a
2 changed files with 30 additions and 10 deletions

View File

@ -0,0 +1,20 @@
// @flow
import { getApp } from '../setup/utils';
const app = getApp();
beforeAll(async () => {
await app.start();
await app.client.waitUntilWindowLoaded();
await app.client.waitUntilTextExists('#sidebar', 'Dashboard', 120000);
});
afterAll(() => app.stop());
describe('Status Pill', () => {
test('should show status pill in the header', async () => expect(
app.client
.waitUntilTextExists('#status-pill', '50.00%')
.getText('#status-pill'),
).resolves.toEqual(expect.stringContaining('50.00%')));
});

View File

@ -78,25 +78,25 @@ export class StatusPill extends Component<Props, State> {
} }
getBlockchainStatus = async () => { getBlockchainStatus = async () => {
const [blockchainErr, blockchaininfo] = await eres( const [blockchainErr, blockchaininfo] = await eres(rpc.getblockchaininfo());
rpc.getblockchaininfo(),
);
const newProgress = blockchaininfo.verificationprogress * 100; const newProgress = blockchaininfo.verificationprogress * 100;
this.setState({ this.setState({
progress: newProgress, progress: newProgress,
...(newProgress > 99.99 ? { ...(newProgress > 99.99
type: 'ready', ? {
icon: readyIcon, type: 'ready',
isSynching: false, icon: readyIcon,
} : {}), isSynching: false,
}
: {}),
}); });
if (blockchainErr) { if (blockchainErr) {
this.setState(() => ({ type: 'error', icon: errorIcon })); this.setState(() => ({ type: 'error', icon: errorIcon }));
} }
} };
render() { render() {
const { const {
@ -105,7 +105,7 @@ export class StatusPill extends Component<Props, State> {
const showPercent = isSynching ? `(${progress.toFixed(2)}%)` : ''; const showPercent = isSynching ? `(${progress.toFixed(2)}%)` : '';
return ( return (
<Wrapper> <Wrapper id='status-pill'>
<Icon src={icon} animated={isSynching} /> <Icon src={icon} animated={isSynching} />
<StatusPillLabel value={`${type} ${showPercent}`} /> <StatusPillLabel value={`${type} ${showPercent}`} />
</Wrapper> </Wrapper>