2019-01-28 10:13:29 -08:00
|
|
|
// @flow
|
|
|
|
|
|
|
|
import React from 'react';
|
2019-01-31 08:41:32 -08:00
|
|
|
import { render, cleanup, queryByText } from 'react-testing-library';
|
2019-01-28 10:13:29 -08:00
|
|
|
import { ThemeProvider } from 'styled-components';
|
|
|
|
import 'jest-dom/extend-expect';
|
|
|
|
|
|
|
|
import { StatusPill } from '../../app/components/status-pill';
|
2019-02-10 09:52:34 -08:00
|
|
|
import { appTheme } from '../../app/theme';
|
2019-01-28 10:13:29 -08:00
|
|
|
|
|
|
|
afterEach(cleanup);
|
|
|
|
|
|
|
|
describe('<StatusPill />', () => {
|
2019-01-31 08:41:32 -08:00
|
|
|
test('should show percentage on status pill syncing', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ThemeProvider theme={appTheme}>
|
2019-02-20 11:36:39 -08:00
|
|
|
<StatusPill
|
|
|
|
getBlockchainStatus={() => Promise.resolve()}
|
|
|
|
nodeSyncProgress={56.0}
|
|
|
|
nodeSyncType='syncing'
|
2019-06-04 17:31:15 -07:00
|
|
|
isRefetching={false}
|
2019-02-20 11:36:39 -08:00
|
|
|
/>
|
2019-01-31 08:41:32 -08:00
|
|
|
</ThemeProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(queryByText(container, /%/i)).toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should hide percentage on status pill', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ThemeProvider theme={appTheme}>
|
2019-02-20 11:36:39 -08:00
|
|
|
<StatusPill
|
|
|
|
getBlockchainStatus={() => Promise.resolve()}
|
|
|
|
nodeSyncProgress={100.0}
|
|
|
|
nodeSyncType='ready'
|
2019-06-04 17:31:15 -07:00
|
|
|
isRefetching={false}
|
2019-02-20 11:36:39 -08:00
|
|
|
/>
|
2019-01-31 08:41:32 -08:00
|
|
|
</ThemeProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(queryByText(container, /%/i)).not.toBeInTheDocument();
|
|
|
|
});
|
|
|
|
|
|
|
|
test('should show error string and hide percentage on status pill', () => {
|
|
|
|
const { container } = render(
|
|
|
|
<ThemeProvider theme={appTheme}>
|
2019-02-20 11:36:39 -08:00
|
|
|
<StatusPill
|
|
|
|
getBlockchainStatus={() => Promise.resolve()}
|
|
|
|
nodeSyncProgress={0.0}
|
|
|
|
nodeSyncType='error'
|
2019-06-04 17:31:15 -07:00
|
|
|
isRefetching={false}
|
2019-02-20 11:36:39 -08:00
|
|
|
/>
|
2019-01-31 08:41:32 -08:00
|
|
|
</ThemeProvider>,
|
|
|
|
);
|
|
|
|
|
|
|
|
expect(queryByText(container, /%/i)).not.toBeInTheDocument();
|
|
|
|
expect(queryByText(container, /error/i)).toBeInTheDocument();
|
2019-01-28 10:13:29 -08:00
|
|
|
});
|
|
|
|
});
|