1
1
import React , { Component } from 'react' ;
2
2
import Metrics from '../src/components/tabs/Metrics' ;
3
- import { describe , expect , test , jest } from '@jest/globals' ;
3
+ import { describe , expect , test , beforeEach , afterEach , jest } from '@jest/globals' ;
4
4
import '@testing-library/jest-dom' ;
5
+ import { MemoryRouter } from 'react-router-dom' ;
5
6
import { Provider } from 'react-redux' ;
6
7
import store from '../src/renderer/store' ;
7
- import { create } from 'react-test-renderer' ;
8
- import { fireEvent , render , screen } from '@testing-library/react' ;
8
+ import { act } from 'react-test-renderer' ;
9
+ import { fireEvent , render , screen , waitFor } from '@testing-library/react' ;
10
+ import fetchMock from 'jest-fetch-mock' ;
9
11
10
12
const props = {
11
- runningList : [ { BlockIO : '1B/2B' , ID : '6f49565a501c' , CPUPerc : '20.00%' , MemPerc : '0.00%' , MemUsage : '5B/6B' , Name : 'checkpoint_nginx_1' , NetIO : '3B/4B' , PIDs : '0' } , { BlockIO : '3B/4B' , ID : '6f49565a501c' , CPUPerc : '30.00%' , MemPerc : '20.00%' , MemUsage : '5B/6B' , Name : 'checkpoint_nginx_2' , NetIO : '5B/6B' , PIDs : '0' } ]
13
+ runningList : [
14
+ {
15
+ ID : 'a802306eeac3' ,
16
+ Name : 'blissful_matsumoto' ,
17
+ Image : 'postgres:15' ,
18
+ CPUPerc : '0.17' ,
19
+ MemPerc : '0.11' ,
20
+ MemUsage : '2.19MiB / 1.94MiB' ,
21
+ NetIO : '796kB/0kB' ,
22
+ BlockIO : '34029.57kB / 4.1kB' ,
23
+ PIDs : '5'
24
+ }
25
+ ] ,
26
+ threshold : [
27
+ 80.00 , // state.session.cpu_threshold:
28
+ 80.00 , // state.session.mem_threshold:
29
+ ] ,
12
30
} ;
13
31
32
+ fetchMock . enableMocks ( ) ;
33
+
34
+ // // This test tab needs work as we are unable to render the metrics component for testing
14
35
// describe('Metrics tab should render', () => {
15
- // beforeEach(()=>{
16
- // render(
17
- // <Provider store={store}>
18
- // <Metrics {...props}/>
19
- // </Provider>
20
- // );
21
- // });
36
+ // beforeEach( async () => {
37
+ // fetch.resetMocks();
22
38
23
- // test('Metrics', ()=>{
24
- // expect(1).toBe(1);
25
- // });
26
- // });
39
+ // async function metricsRenderer(){
40
+ // return <Metrics runningList={props.runningList} threshold={props.threshold}/>;
41
+ // }
27
42
43
+ // const MetricsTab = await metricsRenderer();
44
+ // console.log(MetricsTab);
28
45
46
+ // await act( () => {
47
+ // render(
48
+ // <Provider store={store}>
49
+ // <MemoryRouter initialEntries={['/app/*']}>
50
+ // {/* <Metrics runningList={props.runningList} threshold={props.threshold}/> */ }
51
+ // {MetricsTab}
52
+ // </MemoryRouter>
53
+ // </Provider>
54
+ // );
55
+ // // console.log(screen);
56
+ // screen.debug();
57
+ // });
58
+ // });
59
+ // });
29
60
30
61
//* Dummy Test
31
62
describe ( 'dummy test' , ( ) => {
32
63
test ( 'dummy test' , ( ) => {
33
64
expect ( 2 + 2 ) . toBe ( 4 ) ;
34
65
} ) ;
35
-
36
- } ) ;
37
-
66
+ } ) ;
0 commit comments