Skip to content

Commit 5331ce7

Browse files
author
Lucas Bento
authored
Increase testing coverage (#99)
Increase testing coverage
2 parents 410a422 + c35c533 commit 5331ce7

17 files changed

+504
-1
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,4 +27,7 @@ yarn-error.log*
2727

2828
# IDE
2929
.idea
30-
.vscode
30+
.vscode
31+
32+
# testing
33+
/.jest

src/__tests__/components/Home.spec.js

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import Home from '../../components/pages/Home'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(<Home />)
7+
8+
expect(container).toMatchSnapshot()
9+
})
Lines changed: 173 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,173 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`renders without crashing 1`] = `
4+
<div>
5+
<div
6+
class="sc-jWBwVP eMzqrb"
7+
>
8+
<div
9+
class="ant-card sc-brqgnP jqshtE ant-card-bordered"
10+
>
11+
<div
12+
class="ant-card-body"
13+
>
14+
<div
15+
class="sc-cMljjf bqDeCs"
16+
>
17+
<img
18+
alt="React Native upgrade helper logo"
19+
class="sc-jAaTju iQnFlP"
20+
src="logo.svg"
21+
title="React Native upgrade helper logo"
22+
/>
23+
<a
24+
href="https://react-native-community.github.io/upgrade-helper"
25+
>
26+
<h1
27+
class="sc-jDwBTQ kdxkQr"
28+
>
29+
React Native upgrade helper
30+
</h1>
31+
</a>
32+
<div
33+
class="sc-gPEVay iMFRcs"
34+
>
35+
<div>
36+
ReactGitHubBtn -
37+
Star
38+
</div>
39+
</div>
40+
</div>
41+
<div
42+
class="sc-htpNat hqmgw"
43+
>
44+
<div
45+
class="sc-bdVaJa UoSJW"
46+
>
47+
<h4>
48+
What's your current React Native version?
49+
</h4>
50+
<div
51+
class="ant-select-lg sc-bxivhb iYdHlP sc-bwzfXH jwfMIB ant-select ant-select-enabled ant-select-loading"
52+
>
53+
<div
54+
aria-autocomplete="list"
55+
aria-controls="test-uuid"
56+
aria-expanded="false"
57+
aria-haspopup="true"
58+
class="ant-select-selection
59+
ant-select-selection--single"
60+
role="combobox"
61+
tabindex="0"
62+
>
63+
<div
64+
class="ant-select-selection__rendered"
65+
>
66+
<div
67+
class="ant-select-selection-selected-value"
68+
style="display: block; opacity: 1;"
69+
title=""
70+
/>
71+
</div>
72+
<span
73+
class="ant-select-arrow"
74+
style="user-select: none;"
75+
unselectable="on"
76+
>
77+
<i
78+
aria-label="icon: loading"
79+
class="anticon anticon-loading"
80+
>
81+
<svg
82+
aria-hidden="true"
83+
class="anticon-spin"
84+
data-icon="loading"
85+
fill="currentColor"
86+
focusable="false"
87+
height="1em"
88+
viewBox="0 0 1024 1024"
89+
width="1em"
90+
>
91+
<path
92+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
93+
/>
94+
</svg>
95+
</i>
96+
</span>
97+
</div>
98+
</div>
99+
</div>
100+
<div
101+
class="sc-bdVaJa UoSJW"
102+
>
103+
<h4>
104+
To which version would you like to upgrade?
105+
</h4>
106+
<div
107+
class="ant-select-lg sc-ifAKCX dTveGH sc-bwzfXH jwfMIB ant-select ant-select-enabled ant-select-loading"
108+
>
109+
<div
110+
aria-autocomplete="list"
111+
aria-controls="test-uuid"
112+
aria-expanded="false"
113+
aria-haspopup="true"
114+
class="ant-select-selection
115+
ant-select-selection--single"
116+
role="combobox"
117+
tabindex="0"
118+
>
119+
<div
120+
class="ant-select-selection__rendered"
121+
>
122+
<div
123+
class="ant-select-selection-selected-value"
124+
style="display: block; opacity: 1;"
125+
title=""
126+
/>
127+
</div>
128+
<span
129+
class="ant-select-arrow"
130+
style="user-select: none;"
131+
unselectable="on"
132+
>
133+
<i
134+
aria-label="icon: loading"
135+
class="anticon anticon-loading"
136+
>
137+
<svg
138+
aria-hidden="true"
139+
class="anticon-spin"
140+
data-icon="loading"
141+
fill="currentColor"
142+
focusable="false"
143+
height="1em"
144+
viewBox="0 0 1024 1024"
145+
width="1em"
146+
>
147+
<path
148+
d="M988 548c-19.9 0-36-16.1-36-36 0-59.4-11.6-117-34.6-171.3a440.45 440.45 0 0 0-94.3-139.9 437.71 437.71 0 0 0-139.9-94.3C629 83.6 571.4 72 512 72c-19.9 0-36-16.1-36-36s16.1-36 36-36c69.1 0 136.2 13.5 199.3 40.3C772.3 66 827 103 874 150c47 47 83.9 101.8 109.7 162.7 26.7 63.1 40.2 130.2 40.2 199.3.1 19.9-16 36-35.9 36z"
149+
/>
150+
</svg>
151+
</i>
152+
</span>
153+
</div>
154+
</div>
155+
</div>
156+
</div>
157+
<div
158+
class="sc-EHOje jWoLok"
159+
>
160+
<button
161+
class="ant-btn ant-btn-primary ant-btn-lg"
162+
type="button"
163+
>
164+
<span>
165+
Show me how to upgrade!
166+
</span>
167+
</button>
168+
</div>
169+
</div>
170+
</div>
171+
</div>
172+
</div>
173+
`;
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import CompletedFilesCounter from '../../../components/common/CompletedFilesCounter'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(<CompletedFilesCounter />)
7+
8+
expect(container).toMatchSnapshot()
9+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import DiffViewer from '../../../components/common/DiffViewer'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(<DiffViewer />)
7+
8+
expect(container).toMatchSnapshot()
9+
})
Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import Loading from '../../../components/common/Loading'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(<Loading logo="test.png" />)
7+
8+
expect(container).toMatchSnapshot()
9+
})
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import Markdown from '../../../components/common/Markdown'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(
7+
<Markdown forceBlock={false}># Hello world!</Markdown>
8+
)
9+
10+
expect(container).toMatchSnapshot()
11+
})
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import Select from '../../../components/common/Select'
4+
5+
const options = ['option1', 'option2']
6+
it('renders without crashing', () => {
7+
const { container } = render(<Select title="MyTitle" options={options} />)
8+
9+
expect(container).toMatchSnapshot()
10+
})
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import UsefulContentSection from '../../../components/common/UsefulContentSection'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(
7+
<UsefulContentSection
8+
isLoading={false}
9+
fromVersion="0.60.0"
10+
toVersion="0.61.0"
11+
/>
12+
)
13+
14+
expect(container).toMatchSnapshot()
15+
})
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import React from 'react'
2+
import { render } from '@testing-library/react'
3+
import VersionSelector from '../../../components/common/VersionSelector'
4+
5+
it('renders without crashing', () => {
6+
const { container } = render(<VersionSelector />)
7+
8+
expect(container).toMatchSnapshot()
9+
})
10+
11+
it.skip('triggers the action on button press', () => {
12+
// TODO / pseudocode:
13+
// mock the fetch call for the versions
14+
// render(<VersionSelector />)
15+
// fire an event on FromVersionSelector and ToVersionSelector to choose versions
16+
// fire an event to click on the `upgradeButtonEl` button
17+
// expect that `onShowDiff` method has been called
18+
})

0 commit comments

Comments
 (0)