File tree Expand file tree Collapse file tree 3 files changed +53
-0
lines changed
app/src/__tests__/components Expand file tree Collapse file tree 3 files changed +53
-0
lines changed Original file line number Diff line number Diff line change 1+ import React from 'react' ;
2+ import { renderWithProviders } from 'util/tests' ;
3+ import { prefixTranslation } from 'util/translate' ;
4+ import { SubServerStatusMessage } from 'components/common/SubServerRequired' ;
5+
6+ describe ( 'SubServer Status Message Component' , ( ) => {
7+ const render = ( isDisabled : boolean , errorMessage ?: string ) => {
8+ const cmp = (
9+ < SubServerStatusMessage isDisabled = { isDisabled } errorMessage = { errorMessage } />
10+ ) ;
11+ return renderWithProviders ( cmp ) ;
12+ } ;
13+
14+ it ( 'should display disabled' , ( ) => {
15+ const { getByText } = render ( true ) ;
16+ const { l } = prefixTranslation ( 'cmps.common.SubServerStatus' ) ;
17+ expect ( getByText ( l ( 'isDisabled' ) ) ) . toBeInTheDocument ( ) ;
18+ } ) ;
19+
20+ it ( 'should display error' , ( ) => {
21+ const { getByText } = render ( false ) ;
22+ const { l } = prefixTranslation ( 'cmps.common.SubServerStatus' ) ;
23+ expect ( getByText ( l ( 'isError' ) ) ) . toBeInTheDocument ( ) ;
24+ } ) ;
25+
26+ it ( 'should match error message' , ( ) => {
27+ const { getByText } = render ( false , 'Test error message' ) ;
28+ expect ( getByText ( 'Test error message' ) ) . toBeInTheDocument ( ) ;
29+ } ) ;
30+ } ) ;
Original file line number Diff line number Diff line change @@ -9,6 +9,7 @@ import { formatSats } from 'util/formatters';
99import { renderWithProviders } from 'util/tests' ;
1010import { loopListSwaps } from 'util/tests/sampleData' ;
1111import { createStore , Store } from 'store' ;
12+ import { prefixTranslation } from 'util/translate' ;
1213import LoopPage from 'components/loop/LoopPage' ;
1314
1415const grpcMock = grpc as jest . Mocked < typeof grpc > ;
@@ -216,5 +217,15 @@ describe('LoopPage component', () => {
216217 expect ( store . settingsStore . channelSort . field ) . toBeUndefined ( ) ;
217218 expect ( store . settingsStore . channelSort . descending ) . toBe ( true ) ;
218219 } ) ;
220+
221+ it ( 'should display subserver disabled message' , ( ) => {
222+ const { getByText, store } = render ( ) ;
223+ const { l } = prefixTranslation ( 'cmps.common.SubServerStatus' ) ;
224+
225+ store . subServerStore . subServers . loop . disabled = true ;
226+ render ( ) ;
227+
228+ expect ( getByText ( l ( 'isDisabled' ) ) ) . toBeInTheDocument ( ) ;
229+ } ) ;
219230 } ) ;
220231} ) ;
Original file line number Diff line number Diff line change @@ -3,13 +3,15 @@ import { fireEvent } from '@testing-library/react';
33import { saveAs } from 'file-saver' ;
44import { renderWithProviders } from 'util/tests' ;
55import { createStore , Store } from 'store' ;
6+ import { prefixTranslation } from 'util/translate' ;
67import PoolPage from 'components/pool/PoolPage' ;
78
89describe ( 'PoolPage' , ( ) => {
910 let store : Store ;
1011
1112 beforeEach ( async ( ) => {
1213 store = createStore ( ) ;
14+ await store . fetchAllData ( ) ;
1315 } ) ;
1416
1517 const render = ( ) => {
@@ -27,4 +29,14 @@ describe('PoolPage', () => {
2729 fireEvent . click ( getByText ( 'download.svg' ) ) ;
2830 expect ( saveAs ) . toBeCalledWith ( expect . any ( Blob ) , 'leases.csv' ) ;
2931 } ) ;
32+
33+ it ( 'should display subserver disabled message' , ( ) => {
34+ const { getByText, store } = render ( ) ;
35+ const { l } = prefixTranslation ( 'cmps.common.SubServerStatus' ) ;
36+
37+ store . subServerStore . subServers . pool . disabled = true ;
38+ render ( ) ;
39+
40+ expect ( getByText ( l ( 'isDisabled' ) ) ) . toBeInTheDocument ( ) ;
41+ } ) ;
3042} ) ;
You can’t perform that action at this time.
0 commit comments