11// purpose of this file is to start testing front end/components using RTL
22import React from 'react' ;
3- import { render , screen } from '@testing-library/react' ;
3+ import { render , screen , fireEvent } from '@testing-library/react' ;
44import '@testing-library/jest-dom/extend-expect' ; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
55import Header from './ZoTest' ;
66import MainContainer from '../containers/MainContainer' ;
77import App from '../components/App' ;
88import SwitchAppDropdown from '../components/SwitchApp' ;
9+ import { useStoreContext } from '../store' ;
10+ import Dropdown from '../components/Dropdown' ;
911
1012// notes: beforeAll? can render in here before then testing
1113// after render, can check if the element that has been rendered has props of testing data.
@@ -14,53 +16,44 @@ import SwitchAppDropdown from '../components/SwitchApp';
1416// but the component itself doesnt seem like it's in ts?
1517
1618// Instrinsic Attributes type is a built in TS type that represents defualt attributes like id, className, style
17- // so maybe switchappdropdown needs be assigned a type instead of auto assigned intrinsic?
19+ // so maybe switchappdropdown needs be assigned a type instead of auto assigned intrinsic?
20+ // jest.mock('../store');
1821
19- describe ( 'Tests for components' , ( ) => {
20- describe ( 'Testing Switchapp' , ( ) => {
21- let dropdown ;
22- const props = {
23- currTab : {
24- label : 'Testing' ,
25- value : 12353 ,
26- } ,
27- styles : { } ,
28- options : [ ] ,
29- } ;
30- test ( 'Testing' , ( ) => {
31- render ( < SwitchAppDropdown value = / > ) ;
32- } ) ;
33- } ) ;
34- } ) ;
35-
36- // return (
37- // <Select
38- // className='tab-select-container'
39- // classNamePrefix='tab-select'
40- // value={currTab}
41- // styles={customStyles}
42- // onChange={(e) => {
43- // dispatch(setTab(parseInt(e.value, 10)));
44- // }}
45- // options={tabsArray}
46- // />
47- // );
48- // describe('LabeledText', () => {
49- // let text;
50- // const props = {
51- // label: 'Mega',
52- // text: 'Markets',
22+ // describe('Test for switchapp file', () => {
23+ // const state = {
24+ // currentTab: 100,
25+ // tabs: {
26+ // 100: {
27+ // snapshots: [1, 2, 3, 4],
28+ // viewIndex: 1,
29+ // sliderIndex: 1,
30+ // title: 'hello testing',
31+ // },
32+ // },
33+ // };
34+ // const dropdownCurrTabLabel = {
35+ // value: 100,
36+ // label: 'component',
5337// };
38+ // // create a mock function, passed as param to mocked "useSToreContext" implementation
39+ // const dispatch = jest.fn();
5440
55- // beforeAll(() => {
56- // text = render(<LabeledText {...props} />)
41+ // useStoreContext.mockImplementation(() => [state, dispatch]);
5742
58- // });
43+ // // beforeEach(() => {
44+ // // render(<SwitchAppDropdown />);
45+ // // // mock clear to clear data in between each assertion
46+ // // dispatch.mockClear;
47+ // // });
48+
49+ // // describe('switchapp component render test', () => {
50+ // // fireEvent.change(screen.getByTestId('tab-select-container'), {});
51+ // // });
5952
60- // test('Renders the passed-in text with the label in bold', () => {
61- // expect(text.getByText("Mega:").nextSibling).toHaveTextContent('Markets');
62- // expect(text.getByText('Mega:')).toHaveStyle('font-weight: bold')
53+ // it('SwitchApp component renders', () => {
54+ // render(<SwitchAppDropdown />);
55+ // screen.debug();
56+ // // expect(screen.getByTestId('tab-select-container')).toHaveClass('tab-select-container');
57+ // // expect(screen.getByTestId('tab-select-container')).toHaveValue(dropdownCurrTabLabel);
6358// });
64- // console.log('currTab', currTab);
65- // console.log('customStyles', customStyles);
66- // console.log('tabsArray', tabsArray);
59+ // });
0 commit comments