forked from testing-library/testing-library-docs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
executable file
·310 lines (291 loc) · 9.86 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
/**
* Copyright (c) 2017-present, Facebook, Inc.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
import React from 'react'
import useDocusaurusContext from '@docusaurus/useDocusaurusContext'
import {GridBlock} from '../components/GridBlock'
import {Container} from '../components/Container'
import {Showcase} from '../components/Showcase'
import Layout from '@theme/Layout'
const HomeSplash = props => {
const {language = ''} = props
const {siteConfig} = useDocusaurusContext()
const {baseUrl, customFields} = siteConfig
const docsPart = `${customFields.docsPath ? `${customFields.docsPath}/` : ''}`
const langPart = `${language ? `${language}/` : ''}`
const docUrl = doc => `${baseUrl}${docsPart}${langPart}${doc}`
const SplashContainer = props => (
<div className="homeContainer">
<div className="homeSplashFade">
<div className="wrapper homeWrapper">{props.children}</div>
</div>
</div>
)
const Logo = props => (
<div className="projectLogo">
<img src={props.img_src} alt="Project Logo" />
</div>
)
const ProjectTitle = () => (
<div>
<h2 className="projectTitle">{siteConfig.title}</h2>
<div className="projectTaglineWrapper">
<p className="projectTagline">{siteConfig.tagline}</p>
</div>
</div>
)
const Button = props => (
<a
className="button button--primary button--outline"
href={props.href}
target={props.target}
>
{props.children}
</a>
)
return (
<SplashContainer>
<Logo img_src={`${baseUrl}img/logo-large.png`} />
<div className="inner">
<ProjectTitle siteConfig={siteConfig} />
<div className="pluginWrapper buttonWrapper">
<Button href={'/docs/'}>Get Started</Button>
</div>
</div>
</SplashContainer>
)
}
export default class Index extends React.Component {
render() {
const {config: siteConfig, language = ''} = this.props
const {baseUrl} = siteConfig
const Block = props => (
<Container
padding={['bottom', 'top']}
id={props.id}
background={props.background}
>
<GridBlock
align={props.align || 'center'}
imageAlign={props.imageAlign || 'center'}
contents={props.children}
layout={props.layout}
/>
</Container>
)
const FeatureCallout = () => (
<Container className="" background={'light'} padding={['top', 'bottom']}>
<div style={{textAlign: 'center'}}>
<p>
<i>
The more your tests resemble the way your software is used, <br />
the more confidence they can give you.
</i>
</p>
</div>
</Container>
)
const Problem = () => (
<React.Fragment>
<Block background={'light'} align="left">
{[
{
title: '',
content:
"## The Problem \n - You want tests for your UI that avoid including implementation details and rather focus on making your tests give you the confidence for which they are intended. \n - You want your tests to be maintainable so refactors _(changes to implementation but not functionality)_ don't break your tests and slow you and your team down.",
image: `${baseUrl}img/interrobang-128x128.png`,
imageAlt: 'The problem (picture of a question mark)',
imageAlign: 'left',
},
]}
</Block>
</React.Fragment>
)
const Solution = () => [
<Block background={null} align="left">
{[
{
title: '',
image: `${baseUrl}img/star-128x128.png`,
imageAlign: 'right',
imageAlt: 'The solution (picture of a star)',
content:
'## The Solution \n The Testing Library family of libraries is a very light-weight solution for testing without all the implementation details. The main utilities it provides involve querying for nodes similarly to how users would find them. In this way, testing-library helps ensure your tests give you confidence in your UI code.',
},
]}
</Block>,
<Block background={'light'} align="left">
{[
{
title: 'Guiding Principle',
image: `${baseUrl}img/trophy-128x128.png`,
imageAlign: 'left',
imageAlt: 'The guiding principle (picture of a brick wall)',
content:
'_The more your tests resemble the way your software is used, the more confidence they can give you._',
},
]}
</Block>,
]
const Features = () => (
<Block layout="twoColumn">
{[
{
content:
'Tests only break when your app breaks, not implementation details',
image: `${baseUrl}img/wrench-128x128.png`,
imageAlign: 'top',
title: 'Write Maintainable Tests',
},
{
content: 'Interact with your app the same way as your users',
image: `${baseUrl}img/check-128x128.png`,
imageAlign: 'top',
title: 'Develop with Confidence',
},
{
content:
'Built-in selectors find elements the way users do to help you write inclusive code',
image: `${baseUrl}img/tada-128x128.png`,
imageAlign: 'top',
title: 'Accessible by Default',
},
]}
</Block>
)
const Ecosystem = () => (
<Block layout="fourColumn" background={null}>
{[
{
image: `${baseUrl}img/react-128x128.png`,
imageAlign: 'top',
title: '[React](./docs/react-testing-library/intro)',
},
{
image: `${baseUrl}img/cypress-128x128.png`,
imageAlign: 'top',
title: '[Cypress](./docs/cypress-testing-library/intro)',
},
{
image: `${baseUrl}img/testcafe-128x128.jpg`,
imageAlign: 'top',
title: `[Testcafe](./docs/testcafe-testing-library/intro)`,
},
{
image: `${baseUrl}img/svelte-logo.png`,
imageAlign: 'top',
title: '[Svelte](./docs/svelte-testing-library/intro)',
},
{
image: `${baseUrl}img/vue-400x400.png`,
imageAlign: 'top',
title: '[Vue](./docs/vue-testing-library/intro)',
},
{
image: `${baseUrl}img/angular-250x250.png`,
imageAlign: 'top',
title: '[Angular](./docs/angular-testing-library/intro)',
},
{
image: `${baseUrl}img/reason-200x200.png`,
imageAlign: 'top',
title: '[ReasonReact](./docs/bs-react-testing-library/intro)',
},
{
image: `${baseUrl}img/puppeteer-275x275.png`,
imageAlign: 'top',
title: '[Puppeteer](./docs/pptr-testing-library/intro)',
},
{
image: `${baseUrl}img/react-native-128x128.png`,
imageAlign: 'top',
title: '[React Native](./docs/react-native-testing-library/intro)',
},
{
image: `${baseUrl}img/preact-128x128.png`,
imageAlign: 'top',
title: '[Preact](./docs/preact-testing-library/intro)',
},
{
image: `${baseUrl}img/nightwatch-128x128.png`,
imageAlign: 'top',
title: '[Nightwatch](./docs/nightwatch-testing-library/intro)',
},
{
image: `${baseUrl}img/construction-128x128.png`,
imageAlign: 'top',
title: '[And more...](./docs/ecosystem-user-event)',
},
]}
</Block>
)
const ShowcaseWrapper = () => {
if ((siteConfig.customFields.users || []).length === 0) {
return null
}
const pageUrl = page => baseUrl + (language ? `${language}/` : '') + page
return (
<div className="productShowcaseSection paddingBottom paddingTop">
<h2>Who is Using This?</h2>
<div className="logos">
<Showcase
users={siteConfig.customFields.users.filter(u => u.pinned)}
/>
</div>
<a
className="button button--primary button--outline"
href={pageUrl('users')}
>
More {siteConfig.title} Users
</a>
</div>
)
}
const Awards = () => {
return (
<div className="awardsSection paddingBottom paddingTop">
<h2>Awards</h2>
<Block layout="threeColumn" background={null}>
{[
{
image: `${baseUrl}img/impactful-contribution-award-399x544.png`,
imageAlign: 'top',
imageLink: 'https://osawards.com/react/2019',
imageAlt:
'Winner of the Open Source Awards 2019 in the category "The most impactful contribution to the community"',
},
{
image: `${baseUrl}img/highest-satisfaction-638x574.png`,
imageAlign: 'top',
imageLink: 'https://2020.stateofjs.com/en-US/awards/',
imageAlt:
'Winner of the State of JS 2020 award for the technology with the highest percentage of satisfied users',
},
]}
</Block>
</div>
)
}
return (
<Layout
permalink="/"
title={siteConfig.title}
description={siteConfig.tagline}
>
<HomeSplash siteConfig={siteConfig} language={language} />
<div className="mainContainer">
<FeatureCallout />
<Features />
<Problem />
<Solution />
<ShowcaseWrapper />
<Ecosystem />
<Awards />
</div>
</Layout>
)
}
}