|
| 1 | +import * as React from 'react'; |
| 2 | +import { render, screen, fireEvent, waitFor, cleanup } from '@testing-library/react'; |
| 3 | +import user from '@testing-library/user-event'; |
| 4 | +import '@testing-library/jest-dom'; |
| 5 | +import { TextEncoder } from 'util'; |
| 6 | +global.TextEncoder = TextEncoder; |
| 7 | +import '@testing-library/jest-dom/extend-expect'; |
| 8 | +import Tutorial from '../components/Tutorial'; |
| 9 | +const { Steps } = require('intro.js-react'); |
| 10 | + |
| 11 | +const dispatch = jest.fn(); |
| 12 | +const props = { |
| 13 | + currentTabInApp: undefined, |
| 14 | + dispatch, |
| 15 | +}; |
| 16 | + |
| 17 | +const state = { |
| 18 | + stepsEnabled: true, |
| 19 | +}; |
| 20 | +let currentStepIndex = 5; |
| 21 | + |
| 22 | +describe('Before Tutorial is entered', () => { |
| 23 | + test('How to use button exists', () => { |
| 24 | + render(<Tutorial {...props} />); |
| 25 | + expect(screen.getByText('How to use')).toBeInTheDocument(); |
| 26 | + }); |
| 27 | + |
| 28 | + test('User clicking "How to use" while on map tab button starts map tutorial ', () => { |
| 29 | + props.currentTabInApp = 'map'; |
| 30 | + |
| 31 | + render(<Tutorial {...props} />); |
| 32 | + fireEvent.click(screen.getByRole('button')); |
| 33 | + expect( |
| 34 | + screen.getByText('A performance and state managment tool for React apps.'), |
| 35 | + ).toBeInTheDocument(); |
| 36 | + }); |
| 37 | + |
| 38 | + test('User clicking "How to use" while on performance tab button starts performance tutorial ', () => { |
| 39 | + props.currentTabInApp = 'performance'; |
| 40 | + render(<Tutorial {...props} />); |
| 41 | + fireEvent.click(screen.getByRole('button')); |
| 42 | + expect(screen.getByText('Performance Tab')).toBeInTheDocument(); |
| 43 | + }); |
| 44 | + |
| 45 | + test('User clicking "How to use" while on performance comparison tab, no tutorial available ', () => { |
| 46 | + props.currentTabInApp = 'performance-comparison'; |
| 47 | + currentStepIndex = 1; |
| 48 | + render(<Tutorial {...props} />); |
| 49 | + fireEvent.click(screen.getByRole('button')); |
| 50 | + }); |
| 51 | +}); |
0 commit comments