Skip to content

Commit 3f80759

Browse files
committed
Clean up frontend tests
1 parent 902600e commit 3f80759

File tree

9 files changed

+24
-25
lines changed

9 files changed

+24
-25
lines changed

src/app/__tests__/ActionContainer.test.tsx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -143,8 +143,8 @@ describe('unit testing for ActionContainer', () => {
143143
expect(screen.getByText('MockSwitchApp')).toBeInTheDocument();
144144
});
145145

146-
test('Click works on clear button', async () => {
146+
test('Click works on clear button', () => {
147147
fireEvent.click(screen.getAllByRole('button')[0]);
148-
await expect(dispatch).toHaveBeenCalledTimes(1);
148+
expect(dispatch).toHaveBeenCalledTimes(1);
149149
});
150150
});

src/app/__tests__/ButtonContainer.test.tsx

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ describe('Unit testing for ButtonContainer', () => {
5252
});
5353

5454
describe('When button container is loaded', () => {
55-
test('should have 4 buttons ', () => {
55+
test('it should have 4 buttons', () => {
5656
render(<ButtonsContainer />);
5757
expect(screen.getAllByRole('button')).toHaveLength(4);
5858
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Unlocked');
@@ -62,8 +62,8 @@ describe('Unit testing for ButtonContainer', () => {
6262
});
6363
});
6464

65-
describe('When view is unlock', () => {
66-
test('Button should show as unlocked', () => {
65+
describe('When view is locked', () => {
66+
test('Button should show as locked', () => {
6767
state.tabs['87'].mode.paused = true;
6868
render(<ButtonsContainer />);
6969
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Locked');

src/app/__tests__/ErrorMsg.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,6 @@ const props = {
1313
launchContent: null,
1414
};
1515

16-
const parseError = jest.fn();
17-
1816
describe('unit testing for ErrorContainer.tsx', () => {
1917
describe('When there are no errors', () => {
2018
test('Returns empty div', () => {
@@ -34,7 +32,7 @@ describe('unit testing for ErrorContainer.tsx', () => {
3432
});
3533
});
3634

37-
describe("when there's a Content Script Errorr", () => {
35+
describe("when there's a Content Script Error", () => {
3836
test('Content Script Error related text shows', () => {
3937
props.status.contentScriptLaunched = false;
4038
render(<ErrorMsg {...props} />);

src/app/__tests__/MainContainer.test.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,13 @@ jest.mock('../containers/TravelContainer', () => (props) => {
2323
mockTravelContainer(props);
2424
return <div>mockTravelContainer</div>;
2525
});
26+
2627
const mockButtonsContainer = jest.fn();
2728
jest.mock('../containers/ButtonsContainer', () => (props) => {
2829
mockButtonsContainer(props);
2930
return <div>mockButtonsContainer</div>;
3031
});
32+
3133
const mockErrorContainer = jest.fn();
3234
jest.mock('../containers/ErrorContainer', () => (props) => {
3335
mockErrorContainer(props);

src/app/__tests__/MainSlider.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import React from 'react';
2-
import { render, screen, fireEvent } from '@testing-library/react';
2+
import { render, screen } from '@testing-library/react';
33
import '@testing-library/jest-dom/extend-expect';
44
import { TextEncoder } from 'util';
55
global.TextEncoder = TextEncoder;

src/app/__tests__/TravelContainer.test.tsx

Lines changed: 12 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ const state = {
1515
currentTab: 87,
1616
};
1717

18-
const play = jest.fn();
1918
const dispatch = jest.fn();
2019

2120
jest.mock('../store');
@@ -48,6 +47,7 @@ describe('All elements appear in the TravelContainer module', () => {
4847
test('MainSlider exists in document', () => {
4948
expect(screen.getByText('MockSlider')).toBeInTheDocument();
5049
});
50+
5151
test('Dropdown exists in document', () => {
5252
expect(screen.getByText('mockDropDown')).toBeInTheDocument();
5353
});
@@ -57,7 +57,7 @@ describe('All elements appear in the TravelContainer module', () => {
5757
expect(buttons[1]).toHaveTextContent('<');
5858
});
5959

60-
test('Foward button exists in document', () => {
60+
test('Forward button exists in document', () => {
6161
let buttons = screen.getAllByRole('button');
6262
expect(buttons[2]).toHaveTextContent('>');
6363
});
@@ -69,18 +69,18 @@ describe('Testing backward and forward button', () => {
6969
render(<TravelContainer snapshotsLength={0} />);
7070
});
7171

72-
test('Clicking < Button button will triger button', async () => {
72+
test('Clicking < Button button will trigger button', () => {
7373
let buttons = screen.getAllByRole('button');
7474
expect(buttons[1]).toHaveTextContent('<');
7575
fireEvent.click(buttons[1]);
76-
await expect(dispatch).toHaveBeenCalledTimes(1);
76+
expect(dispatch).toHaveBeenCalledTimes(1);
7777
});
7878

79-
test('Clicking > Button button will triger button', async () => {
79+
test('Clicking > Button button will trigger button', () => {
8080
let buttons = screen.getAllByRole('button');
8181
expect(buttons[2]).toHaveTextContent('>');
8282
fireEvent.click(buttons[2]);
83-
await expect(dispatch).toHaveBeenCalledTimes(1);
83+
expect(dispatch).toHaveBeenCalledTimes(1);
8484
});
8585
});
8686

@@ -94,33 +94,34 @@ describe('Testing play/pause button', () => {
9494
const playButton = screen.getByTestId('play-button-test');
9595
expect(playButton).toBeInTheDocument();
9696
});
97+
9798
test('Play initially says Play', () => {
9899
render(<TravelContainer snapshotsLength={0} />);
99100
const playButton = screen.getByTestId('play-button-test');
100101
expect(playButton.textContent).toBe('Play');
101102
});
102103

103-
test('Clicking Play button will triger button', async () => {
104+
test('Clicking Play button will trigger button', () => {
104105
render(<TravelContainer snapshotsLength={0} />);
105106
const playButton = screen.getByTestId('play-button-test');
106107
expect(playButton.textContent).toBe('Play');
107108
fireEvent.click(playButton);
108-
await expect(dispatch).toHaveBeenCalledTimes(1);
109+
expect(dispatch).toHaveBeenCalledTimes(1);
109110
});
110111

111-
test('Play says Pause when `Playing` is set to False', () => {
112+
test('Play says Pause when `Playing` is set to true', () => {
112113
state.tabs[87].playing = true;
113114
render(<TravelContainer snapshotsLength={0} />);
114115
const playButton = screen.getByTestId('play-button-test');
115116
expect(playButton.textContent).toBe('Pause');
116117
});
117118

118-
test('Clicking Pause button will trigger button', async () => {
119+
test('Clicking Pause button will trigger button', () => {
119120
render(<TravelContainer snapshotsLength={0} />);
120121
const playButton = screen.getByTestId('play-button-test');
121122
expect(playButton.textContent).toBe('Pause');
122123
fireEvent.click(playButton);
123-
await expect(dispatch).toHaveBeenCalledTimes(1);
124+
expect(dispatch).toHaveBeenCalledTimes(1);
124125
state.tabs[87].playing = false;
125126
});
126127
});

src/app/__tests__/Tutorial.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,10 @@ describe('Before Tutorial is entered', () => {
2323

2424
test('User clicking "How to use" while on map tab button starts map tutorial ', () => {
2525
props.currentTabInApp = 'map';
26-
2726
render(<Tutorial {...props} />);
2827
fireEvent.click(screen.getByRole('button'));
2928
expect(
30-
screen.getByText('A performance and state managment tool for React apps.'),
29+
screen.getByText('A performance and state management tool for React apps.'),
3130
).toBeInTheDocument();
3231
});
3332

src/app/__tests__/action.test.tsx

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import React from 'react';
22
import { render, screen } from '@testing-library/react';
3-
import user from '@testing-library/user-event';
43
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
54
import Action from '../components/Action';
65

@@ -53,7 +52,7 @@ describe('unit testing for Action.tsx', () => {
5352
expect(screen.getByPlaceholderText('Snapshot: 3.0')).toBeInTheDocument();
5453
});
5554

56-
test("when there's no have no duration data", () => {
55+
test("when there's no duration data", () => {
5756
props.componentData = undefined;
5857
render(<Action {...props} />);
5958
expect(screen.getAllByRole('button')[0]).toHaveTextContent('NO TIME');

src/app/components/Tutorial.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ export default class Tutorial extends Component<TutorialProps, TutorialState> {
8282
steps = [
8383
{
8484
title: 'Reactime Tutorial',
85-
intro: 'A performance and state managment tool for React apps.',
85+
intro: 'A performance and state management tool for React apps.',
8686
position: 'top',
8787
},
8888
{

0 commit comments

Comments
 (0)