Skip to content

Commit 00dc9c1

Browse files
jasnoominzo-kim
andcommitted
Added Tutorial.test.tsx file
Co-authored-by: minzo-kim <[email protected]>
1 parent d64cba4 commit 00dc9c1

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed

src/app/__tests__jn/Tutorial.test.tsx

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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

Comments
 (0)