Skip to content

Commit b0db7c6

Browse files
jasnoominzo-kim
andcommitted
Formatting fixes
Co-authored-by: minzo-kim <[email protected]>
1 parent 1e7ae38 commit b0db7c6

File tree

6 files changed

+197
-257
lines changed

6 files changed

+197
-257
lines changed

src/app/__tests__jn/Action.test.tsx

Lines changed: 25 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
1-
import React from 'react'
2-
import {render, screen, fireEvent} from '@testing-library/react'
3-
import user from '@testing-library/user-event'
4-
import '@testing-library/jest-dom/extend-expect' // needed this to extend the jest-dom assertions (ex toHaveTextContent)
5-
import Action from '../components/Action'
6-
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import user from '@testing-library/user-event';
4+
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
5+
import Action from '../components/Action';
76

87
// @ts-ignore
98
Action.cleanTime = jest.fn().mockReturnValue();
@@ -16,7 +15,7 @@ describe('unit testing for Action.tsx', () => {
1615
index: 2,
1716
sliderIndex: 2,
1817
isCurrIndex: false,
19-
routePath:"",
18+
routePath: '',
2019
dispatch: jest.fn(),
2120
displayName: '3.0',
2221
componentName: 'App',
@@ -28,41 +27,38 @@ describe('unit testing for Action.tsx', () => {
2827
viewIndex: 2,
2928
handleOnkeyDown: jest.fn(),
3029
};
31-
30+
3231
beforeEach(() => {
33-
props.isCurrIndex = false
34-
props.componentData = {actualDuration: 3.5}
32+
props.isCurrIndex = false;
33+
props.componentData = { actualDuration: 3.5 };
3534
props.dispatch.mockClear();
3635
});
3736

38-
3937
describe('When a component is shown on the page', () => {
40-
test("Action snapshot should be shown as Snapshot: 3.0", () => {
41-
render(<Action {...props} />);
42-
expect(screen.getByPlaceholderText('Snapshot: 3.0')).toBeInTheDocument()
38+
test('Action snapshot should be shown as Snapshot: 3.0', () => {
39+
render(<Action {...props} />);
40+
expect(screen.getByPlaceholderText('Snapshot: 3.0')).toBeInTheDocument();
4341
});
4442

45-
test("two buttons time and Jump when at current snapshot", () => {
43+
test('two buttons time and Jump when at current snapshot', () => {
4644
render(<Action {...props} />);
47-
expect(screen.getAllByRole('button')).toHaveLength(2)
48-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('+00:03.50')
49-
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Jump')
45+
expect(screen.getAllByRole('button')).toHaveLength(2);
46+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('+00:03.50');
47+
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Jump');
5048
});
5149

52-
test("two buttons with time and Current when not at current snapshot", () => {
53-
props.isCurrIndex = true
50+
test('two buttons with time and Current when not at current snapshot', () => {
51+
props.isCurrIndex = true;
5452
render(<Action {...props} />);
55-
expect(screen.getAllByRole('button')).toHaveLength(2)
56-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('+00:03.50')
57-
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Current')
58-
});
53+
expect(screen.getAllByRole('button')).toHaveLength(2);
54+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('+00:03.50');
55+
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Current');
56+
});
5957

6058
test("when there's no have no duration data", () => {
61-
props.componentData = undefined
62-
render(<Action {...props} />);
63-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('NO TIME')
59+
props.componentData = undefined;
60+
render(<Action {...props} />);
61+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('NO TIME');
6462
});
65-
6663
});
67-
6864
});

src/app/__tests__jn/ActionContainer.test.tsx

Lines changed: 22 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
/* eslint-disable @typescript-eslint/no-explicit-any */
22
/* eslint-disable react/jsx-filename-extension */
3-
import React, {useEffect} from 'react'
4-
import {render, screen, fireEvent} from '@testing-library/react'
5-
import '@testing-library/jest-dom/extend-expect'
6-
import ActionContainer from '../containers/ActionContainer'
3+
import React, { useEffect } from 'react';
4+
import { render, screen, fireEvent } from '@testing-library/react';
5+
import '@testing-library/jest-dom/extend-expect';
6+
import ActionContainer from '../containers/ActionContainer';
77
import { useStoreContext } from '../store';
88

9-
10-
119
const state = {
1210
tabs: {
1311
87: {
@@ -108,58 +106,44 @@ const state = {
108106
};
109107

110108
const dispatch = jest.fn();
111-
const resetSlider = jest.fn()
112-
jest.spyOn(React, 'useEffect').mockImplementation(() => jest.fn())
109+
const resetSlider = jest.fn();
110+
jest.spyOn(React, 'useEffect').mockImplementation(() => jest.fn());
113111
jest.mock('../store');
114112
useStoreContext.mockImplementation(() => [state, dispatch]);
115113

116114
const MockRouteDescription = jest.fn();
117115
jest.mock('../components/RouteDescription', () => () => {
118116
MockRouteDescription();
119-
return (
120-
<div>
121-
MockRouteDescription
122-
</div>
123-
);
117+
return <div>MockRouteDescription</div>;
124118
});
125119

126120
const MockSwitchApp = jest.fn();
127121
jest.mock('../components/SwitchApp', () => () => {
128122
MockSwitchApp();
129-
return (
130-
<div>
131-
MockSwitchApp
132-
</div>
133-
);
123+
return <div>MockSwitchApp</div>;
134124
});
135125

136-
137-
138126
describe('unit testing for ActionContainer', () => {
139-
140127
beforeEach(() => {
141128
useStoreContext.mockClear();
142129
dispatch.mockClear();
143-
render(<ActionContainer actionView={true}/>);
130+
render(<ActionContainer actionView={true} />);
144131
});
145132

146-
test("Expect top arrow to be rendered", () => {
147-
expect(screen.getByRole('complementary')).toBeInTheDocument()
148-
149-
});
150-
151-
test("Expect RouteDescription to be rendered", () => {
152-
expect(screen.getAllByText('MockRouteDescription')).toHaveLength(2)
153-
154-
});
133+
test('Expect top arrow to be rendered', () => {
134+
expect(screen.getByRole('complementary')).toBeInTheDocument();
135+
});
155136

156-
test("Expect SwitchApp to be rendered", () => {
157-
expect(screen.getByText('MockSwitchApp')).toBeInTheDocument()
158-
});
137+
test('Expect RouteDescription to be rendered', () => {
138+
expect(screen.getAllByText('MockRouteDescription')).toHaveLength(2);
139+
});
159140

160-
test("Click works on clear button", async () => {
161-
fireEvent.click(screen.getAllByRole('button')[0])
162-
await expect(dispatch).toHaveBeenCalledTimes(1)
163-
});
141+
test('Expect SwitchApp to be rendered', () => {
142+
expect(screen.getByText('MockSwitchApp')).toBeInTheDocument();
143+
});
164144

145+
test('Click works on clear button', async () => {
146+
fireEvent.click(screen.getAllByRole('button')[0]);
147+
await expect(dispatch).toHaveBeenCalledTimes(1);
148+
});
165149
});
Lines changed: 42 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,68 +1,60 @@
1-
import React from 'react'
2-
import {render, screen, fireEvent} from '@testing-library/react'
3-
import userEvent from '@testing-library/user-event'
4-
import '@testing-library/jest-dom/extend-expect' // needed this to extend the jest-dom assertions (ex toHaveTextContent)
1+
import React from 'react';
2+
import { render, screen, fireEvent } from '@testing-library/react';
3+
import userEvent from '@testing-library/user-event';
4+
import '@testing-library/jest-dom/extend-expect'; // needed this to extend the jest-dom assertions (ex toHaveTextContent)
55
import ButtonsContainer from '../containers/ButtonsContainer';
66
import { useStoreContext } from '../store';
77

8-
9-
jest.mock('../store');
8+
jest.mock('../store');
109

1110
describe('Unit testing for ButtonContainer', () => {
12-
13-
beforeEach
11+
beforeEach;
1412

1513
const state = {
16-
tabs: {
17-
87: {
18-
snapshots: [1, 2, 3, 4],
19-
sliderIndex: 0,
20-
viewIndex: -1,
21-
mode: {
22-
paused: false,
23-
locked: false,
24-
persist: false,
14+
tabs: {
15+
87: {
16+
snapshots: [1, 2, 3, 4],
17+
sliderIndex: 0,
18+
viewIndex: -1,
19+
mode: {
20+
paused: false,
21+
locked: false,
22+
persist: false,
23+
},
2524
},
2625
},
27-
},
28-
currentTab: 87,
29-
};
30-
26+
currentTab: 87,
27+
};
3128

29+
const currentTab = state.tabs[state.currentTab];
30+
const dispatch = jest.fn();
3231

32+
useStoreContext.mockImplementation(() => [state, dispatch]);
3333

34-
const currentTab = state.tabs[state.currentTab];
35-
const dispatch = jest.fn();
36-
37-
useStoreContext.mockImplementation(() => [state, dispatch]);
38-
39-
beforeEach(() => {
40-
dispatch.mockClear();
41-
useStoreContext.mockClear();
42-
currentTab.mode = {
43-
paused: false,
44-
persist: false,
45-
};
46-
});
47-
48-
test('should have 5 buttons ', () => {
49-
render(<ButtonsContainer/>)
50-
expect(screen.getAllByRole('button')).toHaveLength(5)
51-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Lock')
52-
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Split')
53-
expect(screen.getAllByRole('button')[2]).toHaveTextContent('Download')
54-
expect(screen.getAllByRole('button')[3]).toHaveTextContent('Upload')
55-
expect(screen.getAllByRole('button')[4]).toHaveTextContent('How to use')
56-
});
34+
beforeEach(() => {
35+
dispatch.mockClear();
36+
useStoreContext.mockClear();
37+
currentTab.mode = {
38+
paused: false,
39+
persist: false,
40+
};
41+
});
5742

43+
test('should have 5 buttons ', () => {
44+
render(<ButtonsContainer />);
45+
expect(screen.getAllByRole('button')).toHaveLength(5);
46+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Lock');
47+
expect(screen.getAllByRole('button')[1]).toHaveTextContent('Split');
48+
expect(screen.getAllByRole('button')[2]).toHaveTextContent('Download');
49+
expect(screen.getAllByRole('button')[3]).toHaveTextContent('Upload');
50+
expect(screen.getAllByRole('button')[4]).toHaveTextContent('How to use');
51+
});
5852

5953
describe('When view is unlock', () => {
60-
6154
test('Button should show as unlocked', () => {
62-
state.tabs['87'].mode.paused = true
63-
render(<ButtonsContainer />)
64-
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Unlock')
55+
state.tabs['87'].mode.paused = true;
56+
render(<ButtonsContainer />);
57+
expect(screen.getAllByRole('button')[0]).toHaveTextContent('Unlock');
6558
});
66-
6759
});
68-
});
60+
});

0 commit comments

Comments
 (0)