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';
9
9
import { renderWithProviders } from 'util/tests' ;
10
10
import { loopListSwaps } from 'util/tests/sampleData' ;
11
11
import { createStore , Store } from 'store' ;
12
+ import { prefixTranslation } from 'util/translate' ;
12
13
import LoopPage from 'components/loop/LoopPage' ;
13
14
14
15
const grpcMock = grpc as jest . Mocked < typeof grpc > ;
@@ -216,5 +217,15 @@ describe('LoopPage component', () => {
216
217
expect ( store . settingsStore . channelSort . field ) . toBeUndefined ( ) ;
217
218
expect ( store . settingsStore . channelSort . descending ) . toBe ( true ) ;
218
219
} ) ;
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
+ } ) ;
219
230
} ) ;
220
231
} ) ;
Original file line number Diff line number Diff line change @@ -3,13 +3,15 @@ import { fireEvent } from '@testing-library/react';
3
3
import { saveAs } from 'file-saver' ;
4
4
import { renderWithProviders } from 'util/tests' ;
5
5
import { createStore , Store } from 'store' ;
6
+ import { prefixTranslation } from 'util/translate' ;
6
7
import PoolPage from 'components/pool/PoolPage' ;
7
8
8
9
describe ( 'PoolPage' , ( ) => {
9
10
let store : Store ;
10
11
11
12
beforeEach ( async ( ) => {
12
13
store = createStore ( ) ;
14
+ await store . fetchAllData ( ) ;
13
15
} ) ;
14
16
15
17
const render = ( ) => {
@@ -27,4 +29,14 @@ describe('PoolPage', () => {
27
29
fireEvent . click ( getByText ( 'download.svg' ) ) ;
28
30
expect ( saveAs ) . toBeCalledWith ( expect . any ( Blob ) , 'leases.csv' ) ;
29
31
} ) ;
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
+ } ) ;
30
42
} ) ;
You can’t perform that action at this time.
0 commit comments