|
| 1 | +// @ts-nocheck |
| 2 | +/* eslint-disable @typescript-eslint/no-explicit-any */ |
| 3 | +/* eslint-disable react/jsx-filename-extension */ |
| 4 | + |
| 5 | +import React from 'react'; |
| 6 | +import { shallow, configure, render } from 'enzyme'; |
| 7 | +import Adapter from 'enzyme-adapter-react-16'; |
| 8 | +import Action from '../components/Action'; |
| 9 | +import RouteDescription from '../components/RouteDescription'; |
| 10 | + |
| 11 | +configure({ adapter: new (Adapter as any)() }); |
| 12 | + |
| 13 | +describe('Unit testing RouteDescription', () => { |
| 14 | + const actionsArr = []; |
| 15 | + |
| 16 | + actionsArr.push( |
| 17 | + <Action |
| 18 | + key="action0" |
| 19 | + index={0} |
| 20 | + state={{}} |
| 21 | + displayName="1.0" |
| 22 | + componentName="App" |
| 23 | + componentData={{ actualDuration: 0 }} |
| 24 | + selected={false} |
| 25 | + last={false} |
| 26 | + dispatch={() => null} |
| 27 | + sliderIndex={0} |
| 28 | + handleOnkeyDown={(e, i) => null} |
| 29 | + viewIndex={undefined} |
| 30 | + isCurrIndex={false} |
| 31 | + routePath="http://localhost:3000/home" |
| 32 | + />, |
| 33 | + ); |
| 34 | + |
| 35 | + actionsArr.push( |
| 36 | + <Action |
| 37 | + key="action1" |
| 38 | + index={0} |
| 39 | + state={{}} |
| 40 | + displayName="2.0" |
| 41 | + componentName="App" |
| 42 | + componentData={{ actualDuration: 0 }} |
| 43 | + selected={false} |
| 44 | + last={false} |
| 45 | + dispatch={() => null} |
| 46 | + sliderIndex={0} |
| 47 | + handleOnkeyDown={(e, i) => null} |
| 48 | + viewIndex={undefined} |
| 49 | + isCurrIndex={false} |
| 50 | + routePath="http://localhost:3000/home" |
| 51 | + />, |
| 52 | + ); |
| 53 | + |
| 54 | + const wrapper = shallow(<RouteDescription actions={actionsArr} />); |
| 55 | + |
| 56 | + test('Renders the correct number of Action components', () => { |
| 57 | + expect(wrapper.find(Action).length).toBe(2); |
| 58 | + }); |
| 59 | + |
| 60 | + test('Renders a single ".route" class', () => { |
| 61 | + expect(wrapper.find('.route').length).toBe(1); |
| 62 | + }); |
| 63 | + |
| 64 | + test('Renders an h3 tag with the correct pathname "Route: <pathname>"', () => { |
| 65 | + expect(wrapper.find('h3').text()).toBe('Route: /home'); |
| 66 | + }); |
| 67 | +}); |
0 commit comments