Skip to content

Commit ec086b2

Browse files
committed
Merge branch 'feature-testing' of https://github.com/oslabs-beta/reactime19.0 into minzo-feature-testing
2 parents 4c4841c + 00dc9c1 commit ec086b2

File tree

2 files changed

+64
-0
lines changed

2 files changed

+64
-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+
});
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import React from 'react';
2+
import { render } from '@testing-library/react';
3+
import '@testing-library/jest-dom/extend-expect';
4+
import WebMetrics from '../components/WebMetrics';
5+
6+
jest.mock('react-apexcharts', () => ({ __esModule: true, default: () => <div /> }));
7+
8+
describe('WebMetrics graph testing', () => {
9+
test('should have 1 div with class name "metric" ', () => {
10+
const { container } = render(<WebMetrics />);
11+
expect(container.getElementsByClassName('metric').length).toBe(1);
12+
});
13+
});

0 commit comments

Comments
 (0)