Skip to content

Commit 55aef96

Browse files
committed
test txt folder
1 parent 454c1b5 commit 55aef96

File tree

8 files changed

+251
-0
lines changed

8 files changed

+251
-0
lines changed
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+

src/app/__tests_minzo__/ActionContainer.test.tsx

Whitespace-only changes.
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
// purpose of this file is to start testing front end/components using RTL
2+
import React from 'react';
3+
import { render, screen, fireEvent } from '@testing-library/react';
4+
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
5+
6+
import Dropdown from '../components/Dropdown';
7+
8+
// interface DropdownProps {
9+
// selectedSpeed: { value: number; label: string };
10+
// speeds: { value: number; label: string }[];
11+
// setSpeed: () => void;
12+
// }
13+
14+
describe('Dropdown test', () => {
15+
const speeds = [
16+
{ value: 1, label: 'test1' },
17+
{ value: 2, label: 'test2' },
18+
{ value: 3, label: 'test3' },
19+
];
20+
// make a hook call into a jest mock
21+
const setSpeed = jest.fn();
22+
23+
// test 1: test to see if it renders the label correctly
24+
test('renders Dropdown with correct info', () => {
25+
// find a specific speed from array. could be testing each? one for now.
26+
const currSpeed = speeds[0];
27+
// you pass in what is expected from TS, passed into Dropdown NOT the return statement.
28+
// in this case, the dropdownprops interface.
29+
// assign it to a container which is the document i guess?
30+
const { container } = render(
31+
<Dropdown speeds={speeds} setSpeed={setSpeed} selectedSpeed={currSpeed} />,
32+
);
33+
// then we can query the container like a normal dom, with query selector
34+
expect(container.querySelector('.react-select__single-value')).toHaveTextContent('test1');
35+
// want to test for speeds but not showing up?
36+
// screen.debug is only what is rendered, so no functions
37+
// test to see if setSpeed is called
38+
//
39+
// screen.debug();
40+
});
41+
42+
// test 2: test to see if functions are called properly on changes.
43+
// test('setSpeed mock function is called correctly when speed is changed', () => {
44+
// const currSpeed = speeds[0];
45+
// const { container } = render(
46+
// <Dropdown speeds={speeds} setSpeed={setSpeed} selectedSpeed={currSpeed} />,
47+
// );
48+
// // grab the dropdown
49+
// const dropdown = container.querySelector('.react-select__input');
50+
// // console.log(dropdown);
51+
// // select new speed from speeds arr
52+
// fireEvent.mouseDown(dropdown);
53+
// // const newSpeed = speeds[1];
54+
// const newSpeed = container.querySelector('[data-value="2"]');
55+
// // console.log('new speed', newSpeed);
56+
// fireEvent.click(newSpeed);
57+
// // check to see that setspeeds has been called with the new speed.
58+
// expect(setSpeed).toHaveBeenCalled();
59+
// expect(setSpeed).toHaveBeenCalledWith(speeds[1]);
60+
61+
// // check to see if new speed is rendered on the dom or something
62+
// });
63+
});
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
// import App from '../components/App';
4+
const App = require('../components/App').default;
5+
// import { TextEncoder } from 'util';
6+
// global.TextEncoder = TextEncoder;
7+
8+
// // error, text encoder again
9+
// jest.mock('../../../node_modules/intro.js/introjs.css', () => jest.fn());
10+
11+
// describe('Test to see if App renders', () => {
12+
// test('testing', () => {
13+
// const { container } = render(<App />);
14+
// expect(container).toBeDefined();
15+
// });
16+
// });
17+
18+
// jest.mock('../../../node_modules/intro.js/introjs.css', () => jest.fn());
19+
20+
// it('renders without crashing', () => {
21+
// const { container } = render(<App />);
22+
// expect(container).toBeDefined();
23+
// });
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import RouteDescription from '../components/RouteDescription';
5+
6+
type RouteProps = {
7+
actions: JSX.Element[];
8+
};
9+
10+
// currently, can't test the url. not sure why.
11+
render(<RouteDescription actions={[]} />);
12+
screen.debug();
13+
14+
describe('Unit Testing for RouteDescription.tsx', () => {
15+
// test actions, passing url into JSX component. currently cannot.
16+
// TypeError: Invalid URL: testUrlString
17+
// const url = new URL('testUrlString');
18+
const actions = [<p>hello action</p>];
19+
20+
test('Test that RouteDescription renders', () => {
21+
const url = { pathname: 'testURL' };
22+
const { container } = render(<RouteDescription actions={actions} />);
23+
expect(container).toBeInTheDocument();
24+
});
25+
});
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import SwitchAppDropdown from '../components/SwitchApp';
5+
6+
// describe('Unit testin for SwitchApp.tsx');
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
// import React from 'react';
2+
// import { render, screen, fireEvent } from '@testing-library/react';
3+
// import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
4+
// import RadialGraph from '../components/WebMetrics';
5+
6+
// describe('WebMetrics/Radial Graph test', () => {
7+
// // check to see if renders
8+
// test('renders Radial Graph with info', () => {
9+
// const { container } = render(<RadialGraph />);
10+
// });
11+
// });
12+
// // const radialGraph = (props) => {
13+
// const state = {
14+
// series: [props.series],
15+
// options: {
16+
// colors: [props.color],
17+
// chart: {
18+
// height: 100,
19+
// width: 100,
20+
// type: 'radialBar',
21+
// toolbar: {
22+
// show: false,
23+
// },
24+
// },
25+
// plotOptions: {
26+
// radialBar: {
27+
// startAngle: -135,
28+
// endAngle: 135,
29+
// hollow: {
30+
// margin: 0,
31+
// size: '75%',
32+
// background: '#242529',
33+
// image: undefined,
34+
// imageOffsetX: 0,
35+
// imageOffsetY: 0,
36+
// position: 'front',
37+
// dropShadow: {
38+
// enabled: false,
39+
// top: 3,
40+
// left: 0,
41+
// blur: 4,
42+
// opacity: 0.24,
43+
// },
44+
// },
45+
// track: {
46+
// background: '#fff',
47+
// strokeWidth: '3%',
48+
// margin: 0, // margin is in pixels
49+
// dropShadow: {
50+
// enabled: true,
51+
// top: -3,
52+
// left: 0,
53+
// blur: 4,
54+
// opacity: 0.35,
55+
// },
56+
// },
57+
58+
// dataLabels: {
59+
// show: true,
60+
// name: {
61+
// offsetY: -10,
62+
// show: true,
63+
// color: '#fff',
64+
// fontSize: '24px',
65+
// },
66+
// value: {
67+
// formatter: props.formatted,
68+
// color: '#fff',
69+
// fontSize: '16px',
70+
// show: true,
71+
// },
72+
// },
73+
// },
74+
// },
75+
// fill: {
76+
// type: 'solid',
77+
// gradient: {
78+
// shade: 'dark',
79+
// type: 'horizontal',
80+
// shadeIntensity: 0.1,
81+
// gradientToColors: [props.color],
82+
// inverseColors: false,
83+
// opacityFrom: 1,
84+
// opacityTo: 1,
85+
// stops: [0, 100],
86+
// },
87+
// },
88+
// stroke: {
89+
// lineCap: 'flat',
90+
// },
91+
// labels: [props.label],
92+
// },
93+
// };
94+
95+
// // // This updates currentTabInApp which is used to determine what tutorial to display (depending on the active tab within Reactime)
96+
// // // Code is commented out because it interferes with the testing suite
97+
// // // const [ store, dispatch] = useStoreContext();
98+
// // // useEffect(() => {
99+
// // // dispatch(setCurrentTabInApp('history'));
100+
// // // }, []);
101+
102+
// // const optionsCursorTrueWithMargin = {
103+
// // followCursor: true,
104+
// // shiftX: 20,
105+
// // shiftY: 0,
106+
// // };
107+
108+
// // return (
109+
// // <div className='metric'>
110+
// // <ReactHover options={optionsCursorTrueWithMargin}>
111+
// // <Trigger type='trigger'>
112+
// // <div id='chart'>
113+
// // <Charts
114+
// // options={state.options}
115+
// // series={state.series}
116+
// // type='radialBar'
117+
// // height={200}
118+
// // width={200}
119+
// // />
120+
// // </div>
121+
// // </Trigger>
122+
// // <Hover type='hover'>
123+
// // <div style={{ zIndex: 1, position: 'relative', padding: '0.5rem 1rem' }} id='hover-box'>
124+
// // <p>
125+
// // <strong>{props.name}</strong>
126+
// // </p>
127+
// // <p>{props.description}</p>
128+
// // </div>
129+
// // </Hover>
130+
// // </ReactHover>
131+
// // </div>
132+
// // );
133+
// // };

src/app/__tests_minzo__/test.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)