From 8fc737081ac688188f29833cdfe02d910db15fda Mon Sep 17 00:00:00 2001 From: George Lima Date: Wed, 23 Jan 2019 12:40:18 -0300 Subject: [PATCH] test(status-pill): add StatusPill tests --- __tests__/e2e/status-pill.test.js | 20 ++++++++++++++++++++ app/components/status-pill.js | 20 ++++++++++---------- 2 files changed, 30 insertions(+), 10 deletions(-) create mode 100644 __tests__/e2e/status-pill.test.js diff --git a/__tests__/e2e/status-pill.test.js b/__tests__/e2e/status-pill.test.js new file mode 100644 index 0000000..2d40f77 --- /dev/null +++ b/__tests__/e2e/status-pill.test.js @@ -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%'))); +}); diff --git a/app/components/status-pill.js b/app/components/status-pill.js index 235f50a..a59521c 100644 --- a/app/components/status-pill.js +++ b/app/components/status-pill.js @@ -78,25 +78,25 @@ export class StatusPill extends Component { } 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 { const showPercent = isSynching ? `(${progress.toFixed(2)}%)` : ''; return ( - +