mirror of
https://github.com/lightninglabs/lightning-terminal.git
synced 2026-08-13 12:33:36 +02:00
test: add unit tests for NodeStatus component
This commit is contained in:
parent
6b77767bc4
commit
49d12a35a9
3 changed files with 48 additions and 0 deletions
26
app/src/__tests__/components/NodeStatus.spec.tsx
Normal file
26
app/src/__tests__/components/NodeStatus.spec.tsx
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
import React from 'react';
|
||||
import { renderWithProviders } from 'util/tests';
|
||||
import NodeStatus from 'components/NodeStatus';
|
||||
|
||||
describe('NodeStatus component', () => {
|
||||
const render = () => {
|
||||
return renderWithProviders(<NodeStatus />);
|
||||
};
|
||||
|
||||
it('should display the Node Status label', () => {
|
||||
const { getByText } = render();
|
||||
expect(getByText('Node Status')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should display the lightning balance', () => {
|
||||
const { getByText, store } = render();
|
||||
store.balances = { channelBalance: 123, walletBalance: 0 };
|
||||
expect(getByText('123 SAT')).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it('should display the bitcoin balance', () => {
|
||||
const { getByText, store } = render();
|
||||
store.balances = { channelBalance: 0, walletBalance: 234 };
|
||||
expect(getByText('234')).toBeInTheDocument();
|
||||
});
|
||||
});
|
||||
1
app/src/util/tests/index.ts
Normal file
1
app/src/util/tests/index.ts
Normal file
|
|
@ -0,0 +1 @@
|
|||
export { default as renderWithProviders } from './renderWithProviders';
|
||||
21
app/src/util/tests/renderWithProviders.tsx
Normal file
21
app/src/util/tests/renderWithProviders.tsx
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
import React from 'react';
|
||||
import { render } from '@testing-library/react';
|
||||
import { Store, StoreProvider } from 'store';
|
||||
import { ThemeProvider } from 'components/theme';
|
||||
|
||||
/**
|
||||
* Renders a component inside of the theme and mobx store providers
|
||||
* to supply context items needed to render some child components
|
||||
* @param component the component under test to render
|
||||
*/
|
||||
const renderWithProviders = (component: React.ReactElement) => {
|
||||
const store = new Store();
|
||||
const result = render(
|
||||
<StoreProvider store={store}>
|
||||
<ThemeProvider>{component}</ThemeProvider>
|
||||
</StoreProvider>,
|
||||
);
|
||||
return { ...result, store };
|
||||
};
|
||||
|
||||
export default renderWithProviders;
|
||||
Loading…
Add table
Add a link
Reference in a new issue