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