11import React , { Component } from 'react' ;
22import 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' ;
44import '@testing-library/jest-dom' ;
5+ import { MemoryRouter } from 'react-router-dom' ;
56import { Provider } from 'react-redux' ;
67import 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' ;
911
1012const 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+ ] ,
1230} ;
1331
32+ fetchMock . enableMocks ( ) ;
33+
34+ // // This test tab needs work as we are unable to render the metrics component for testing
1435// 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();
2238
23- // test('Metrics', ()=>{
24- // expect(1).toBe(1);
25- // });
26- // });
39+ // async function metricsRenderer(){
40+ // return <Metrics runningList={props.runningList} threshold={props.threshold}/>;
41+ // }
2742
43+ // const MetricsTab = await metricsRenderer();
44+ // console.log(MetricsTab);
2845
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+ // });
2960
3061//* Dummy Test
3162describe ( 'dummy test' , ( ) => {
3263 test ( 'dummy test' , ( ) => {
3364 expect ( 2 + 2 ) . toBe ( 4 ) ;
3465 } ) ;
35-
36- } ) ;
37-
66+ } ) ;
0 commit comments