test(status-pill): add StatusPill tests
This commit is contained in:
parent
e918f319ba
commit
8fc737081a
|
@ -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%')));
|
||||
});
|
|
@ -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 ? {
|
||||
...(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>
|
||||
|
|
Loading…
Reference in New Issue