Browse Source

fix(clightning): do not show Sidebar c-lightning nodes on Windows

master
jamaljsr 5 years ago
parent
commit
5afe8a2916
  1. 19
      src/components/designer/default/DefaultSidebar.spec.tsx
  2. 10
      src/components/designer/default/DefaultSidebar.tsx

19
src/components/designer/default/DefaultSidebar.spec.tsx

@ -1,6 +1,7 @@
import React from 'react';
import { REACT_FLOW_CHART } from '@mrblenny/react-flow-chart';
import { createEvent, fireEvent } from '@testing-library/dom';
import os from 'os';
import { LndVersion, Status } from 'shared/types';
import { initChartFromNetwork } from 'utils/chart';
import {
@ -12,6 +13,16 @@ import {
} from 'utils/tests';
import DefaultSidebar from './DefaultSidebar';
jest.mock('os', () => {
const actualOS = jest.requireActual('os');
return {
...actualOS,
platform: jest.fn().mockReturnValue('darwin'),
};
});
const mockOS = os as jest.Mocked<typeof os>;
describe('DefaultSidebar Component', () => {
const renderComponent = (status?: Status) => {
const network = getNetwork(1, 'test network', status);
@ -49,6 +60,14 @@ describe('DefaultSidebar Component', () => {
expect(getAllByText('latest')).toHaveLength(3);
});
it('should not display c-lightning nodes on Windows', () => {
mockOS.platform.mockReturnValue('win32');
const { queryByText, getAllByText, getByRole } = renderComponent();
expect(queryByText('c-lightning')).not.toBeInTheDocument();
fireEvent.click(getByRole('switch'));
expect(getAllByText('latest')).toHaveLength(2);
});
it('should display a draggable LND node', () => {
const { getByText } = renderComponent();
expect(getByText(`LND v${LndVersion.latest}`)).toBeInTheDocument();

10
src/components/designer/default/DefaultSidebar.tsx

@ -5,6 +5,7 @@ import { usePrefixedTranslation } from 'hooks';
import { BitcoindVersion, CLightningVersion, LndVersion } from 'shared/types';
import { useStoreActions, useStoreState } from 'store';
import { Network } from 'types';
import { isWindows } from 'utils/system';
import bitcoindLogo from 'resources/bitcoin.svg';
import clightningLogo from 'resources/clightning.png';
import lndLogo from 'resources/lnd.png';
@ -54,9 +55,12 @@ const DefaultSidebar: React.FC<Props> = ({ network }) => {
const nodes = [
...Object.entries(LndVersion).map(mapVersion('LND', lndLogo, 'lnd')),
...Object.entries(CLightningVersion).map(
mapVersion('c-lightning', clightningLogo, 'c-lightning'),
),
// do not display c-lightning nodes on Windows yet :(
...(isWindows()
? []
: Object.entries(CLightningVersion).map(
mapVersion('c-lightning', clightningLogo, 'c-lightning'),
)),
...Object.entries(BitcoindVersion).map(
mapVersion('Bitcoin Core', bitcoindLogo, 'bitcoind'),
),

Loading…
Cancel
Save