-
Notifications
You must be signed in to change notification settings - Fork 47.3k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* add fixture components * add a few more options and styles * Test fixture updates - Pull in React from window global - Add field to TestCase for fix PR links - Update some styles * Remove unused Fixture.Result comment * Remove leading # from resolvedBy link * Implement tag loading utility that caches response Don't bust the cache doing feature detection COME ON * Use 'local' without version for option
- Loading branch information
Showing
15 changed files
with
701 additions
and
18 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
const React = window.React; | ||
|
||
const propTypes = { | ||
children: React.PropTypes.node.isRequired, | ||
}; | ||
|
||
class Fixture extends React.Component { | ||
render() { | ||
const { children } = this.props; | ||
|
||
return ( | ||
<div className="test-fixture"> | ||
{children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
Fixture.propTypes = propTypes; | ||
|
||
export default Fixture |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import React from 'react'; | ||
|
||
const propTypes = { | ||
title: React.PropTypes.node.isRequired, | ||
description: React.PropTypes.node.isRequired, | ||
}; | ||
|
||
class FixtureSet extends React.Component { | ||
|
||
render() { | ||
const { title, description, children } = this.props; | ||
|
||
return ( | ||
<div> | ||
<h1>{title}</h1> | ||
{description && ( | ||
<p>{description}</p> | ||
)} | ||
|
||
{children} | ||
</div> | ||
); | ||
} | ||
} | ||
|
||
FixtureSet.propTypes = propTypes; | ||
|
||
export default FixtureSet |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,145 @@ | ||
import cn from 'classnames'; | ||
import semver from 'semver'; | ||
import React from 'react'; | ||
import { parse } from 'query-string'; | ||
import { semverString } from './propTypes' | ||
|
||
const propTypes = { | ||
children: React.PropTypes.node.isRequired, | ||
title: React.PropTypes.node.isRequired, | ||
resolvedIn: semverString, | ||
resolvedBy: React.PropTypes.string | ||
}; | ||
|
||
class TestCase extends React.Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.state = { | ||
complete: false, | ||
}; | ||
} | ||
|
||
handleChange = (e) => { | ||
this.setState({ | ||
complete: e.target.checked | ||
}) | ||
}; | ||
|
||
render() { | ||
const { | ||
title, | ||
description, | ||
resolvedIn, | ||
resolvedBy, | ||
affectedBrowsers, | ||
children, | ||
} = this.props; | ||
|
||
let { complete } = this.state; | ||
|
||
const { version } = parse(window.location.search); | ||
const isTestRelevant = ( | ||
!version || | ||
!resolvedIn || | ||
semver.gte(version, resolvedIn) | ||
); | ||
|
||
complete = !isTestRelevant || complete; | ||
|
||
return ( | ||
<section | ||
className={cn( | ||
"test-case", | ||
complete && 'test-case--complete' | ||
)} | ||
> | ||
<h2 className="test-case__title type-subheading"> | ||
<label> | ||
<input | ||
className="test-case__title__check" | ||
type="checkbox" | ||
checked={complete} | ||
onChange={this.handleChange} | ||
/> | ||
{' '}{title} | ||
</label> | ||
</h2> | ||
|
||
<dl className="test-case__details"> | ||
{resolvedIn && ( | ||
<dt>First supported in: </dt>)} | ||
{resolvedIn && ( | ||
<dd> | ||
<a href={'https://github.com/facebook/react/tag/v' + resolvedIn}> | ||
<code>{resolvedIn}</code> | ||
</a> | ||
</dd> | ||
)} | ||
|
||
{resolvedBy && ( | ||
<dt>Fixed by: </dt>)} | ||
{resolvedBy && ( | ||
<dd> | ||
<a href={'https://github.com/facebook/react/pull/' + resolvedBy.slice(1)}> | ||
<code>{resolvedBy}</code> | ||
</a> | ||
</dd> | ||
)} | ||
|
||
{affectedBrowsers && | ||
<dt>Affected browsers: </dt>} | ||
{affectedBrowsers && | ||
<dd>{affectedBrowsers}</dd> | ||
} | ||
</dl> | ||
|
||
<p className="test-case__desc"> | ||
{description} | ||
</p> | ||
|
||
<div className="test-case__body"> | ||
{!isTestRelevant &&( | ||
<p className="test-case__invalid-version"> | ||
<strong>Note:</strong> This test case was fixed in a later version of React. | ||
This test is not expected to pass for the selected version, and that's ok! | ||
</p> | ||
)} | ||
|
||
{children} | ||
</div> | ||
</section> | ||
); | ||
} | ||
} | ||
|
||
TestCase.propTypes = propTypes; | ||
|
||
TestCase.Steps = class extends React.Component { | ||
render() { | ||
const { children } = this.props; | ||
return ( | ||
<div> | ||
<h3>Steps to reproduce:</h3> | ||
<ol> | ||
{children} | ||
</ol> | ||
</div> | ||
) | ||
} | ||
} | ||
|
||
TestCase.ExpectedResult = class extends React.Component { | ||
render() { | ||
const { children } = this.props | ||
return ( | ||
<div> | ||
<h3>Expected Result:</h3> | ||
<p> | ||
{children} | ||
</p> | ||
</div> | ||
) | ||
} | ||
} | ||
export default TestCase |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
61 changes: 61 additions & 0 deletions
61
fixtures/dom/src/components/fixtures/input-change-events/InputPlaceholderFixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
import React from 'react'; | ||
|
||
import Fixture from '../../Fixture'; | ||
|
||
|
||
|
||
class InputPlaceholderFixture extends React.Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.state = { | ||
placeholder: 'A placeholder', | ||
changeCount: 0, | ||
}; | ||
} | ||
|
||
handleChange = () => { | ||
this.setState(({ changeCount }) => { | ||
return { | ||
changeCount: changeCount + 1 | ||
} | ||
}) | ||
} | ||
handleGeneratePlaceholder = () => { | ||
this.setState({ | ||
placeholder: `A placeholder: ${Math.random() * 100}` | ||
}) | ||
} | ||
|
||
handleReset = () => { | ||
this.setState({ | ||
changeCount: 0, | ||
}) | ||
} | ||
|
||
render() { | ||
const { placeholder, changeCount } = this.state; | ||
const color = changeCount === 0 ? 'green' : 'red'; | ||
|
||
return ( | ||
<Fixture> | ||
<input | ||
type='text' | ||
placeholder={placeholder} | ||
onChange={this.handleChange} | ||
/> | ||
{' '} | ||
<button onClick={this.handleGeneratePlaceholder}> | ||
Change placeholder | ||
</button> | ||
|
||
<p style={{ color }}> | ||
<code>onChange</code>{' calls: '}<strong>{changeCount}</strong> | ||
</p> | ||
<button onClick={this.handleReset}>Reset count</button> | ||
</Fixture> | ||
) | ||
} | ||
} | ||
|
||
export default InputPlaceholderFixture; |
52 changes: 52 additions & 0 deletions
52
fixtures/dom/src/components/fixtures/input-change-events/RadioClickFixture.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
import React from 'react'; | ||
|
||
import Fixture from '../../Fixture'; | ||
|
||
class RadioClickFixture extends React.Component { | ||
constructor(props, context) { | ||
super(props, context); | ||
|
||
this.state = { | ||
changeCount: 0, | ||
}; | ||
} | ||
|
||
handleChange = () => { | ||
this.setState(({ changeCount }) => { | ||
return { | ||
changeCount: changeCount + 1 | ||
} | ||
}) | ||
} | ||
|
||
handleReset = () => { | ||
this.setState({ | ||
changeCount: 0, | ||
}) | ||
} | ||
|
||
render() { | ||
const { changeCount } = this.state; | ||
const color = changeCount === 0 ? 'green' : 'red'; | ||
|
||
return ( | ||
<Fixture> | ||
<label> | ||
<input | ||
defaultChecked | ||
type='radio' | ||
onChange={this.handleChange} | ||
/> | ||
Test case radio input | ||
</label> | ||
{' '} | ||
<p style={{ color }}> | ||
<code>onChange</code>{' calls: '}<strong>{changeCount}</strong> | ||
</p> | ||
<button onClick={this.handleReset}>Reset count</button> | ||
</Fixture> | ||
) | ||
} | ||
} | ||
|
||
export default RadioClickFixture; |
Oops, something went wrong.