From 2757a53fa5546236bdfa498724a270cf8db76e89 Mon Sep 17 00:00:00 2001 From: Jason Quense Date: Thu, 2 Mar 2017 14:38:27 -0500 Subject: [PATCH] Add fixture components (#8860) * 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 --- fixtures/dom/package.json | 4 +- fixtures/dom/src/components/Fixture.js | 21 +++ fixtures/dom/src/components/FixtureSet.js | 28 ++++ fixtures/dom/src/components/Header.js | 9 +- fixtures/dom/src/components/TestCase.js | 145 ++++++++++++++++++ fixtures/dom/src/components/fixtures/index.js | 5 +- .../InputPlaceholderFixture.js | 61 ++++++++ .../input-change-events/RadioClickFixture.js | 52 +++++++ .../RangeKeyboardFixture.js | 75 +++++++++ .../fixtures/input-change-events/index.js | 81 ++++++++++ .../components/fixtures/text-inputs/index.js | 4 +- fixtures/dom/src/components/propTypes.js | 16 ++ fixtures/dom/src/style.css | 144 +++++++++++++++-- fixtures/dom/src/tags.js | 70 +++++++++ fixtures/dom/yarn.lock | 4 + 15 files changed, 701 insertions(+), 18 deletions(-) create mode 100644 fixtures/dom/src/components/Fixture.js create mode 100644 fixtures/dom/src/components/FixtureSet.js create mode 100644 fixtures/dom/src/components/TestCase.js create mode 100644 fixtures/dom/src/components/fixtures/input-change-events/InputPlaceholderFixture.js create mode 100644 fixtures/dom/src/components/fixtures/input-change-events/RadioClickFixture.js create mode 100644 fixtures/dom/src/components/fixtures/input-change-events/RangeKeyboardFixture.js create mode 100644 fixtures/dom/src/components/fixtures/input-change-events/index.js create mode 100644 fixtures/dom/src/components/propTypes.js create mode 100644 fixtures/dom/src/tags.js diff --git a/fixtures/dom/package.json b/fixtures/dom/package.json index cc109e10018fb..5de1a7d4b8d17 100644 --- a/fixtures/dom/package.json +++ b/fixtures/dom/package.json @@ -6,9 +6,11 @@ "react-scripts": "0.8.4" }, "dependencies": { + "classnames": "^2.2.5", "query-string": "^4.2.3", "react": "^15.4.1", - "react-dom": "^15.4.1" + "react-dom": "^15.4.1", + "semver": "^5.3.0" }, "scripts": { "start": "react-scripts start", diff --git a/fixtures/dom/src/components/Fixture.js b/fixtures/dom/src/components/Fixture.js new file mode 100644 index 0000000000000..1f6ef9ba09997 --- /dev/null +++ b/fixtures/dom/src/components/Fixture.js @@ -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 ( +
+ {children} +
+ ); + } +} + +Fixture.propTypes = propTypes; + +export default Fixture diff --git a/fixtures/dom/src/components/FixtureSet.js b/fixtures/dom/src/components/FixtureSet.js new file mode 100644 index 0000000000000..9c6e8581eba4b --- /dev/null +++ b/fixtures/dom/src/components/FixtureSet.js @@ -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 ( +
+

{title}

+ {description && ( +

{description}

+ )} + + {children} +
+ ); + } +} + +FixtureSet.propTypes = propTypes; + +export default FixtureSet diff --git a/fixtures/dom/src/components/Header.js b/fixtures/dom/src/components/Header.js index fb9d143f0ff43..83f77eee31c20 100644 --- a/fixtures/dom/src/components/Header.js +++ b/fixtures/dom/src/components/Header.js @@ -1,4 +1,5 @@ import { parse, stringify } from 'query-string'; +import getVersionTags from '../tags'; const React = window.React; const Header = React.createClass({ @@ -9,13 +10,12 @@ const Header = React.createClass({ return { version, versions }; }, componentWillMount() { - fetch('https://api.github.com/repos/facebook/react/tags', { mode: 'cors' }) - .then(res => res.json()) + getVersionTags() .then(tags => { let versions = tags.map(tag => tag.name.slice(1)); - versions = ['local', ...versions]; + versions = [`local`, ...versions]; this.setState({ versions }); - }); + }) }, handleVersionChange(event) { const query = parse(window.location.search); @@ -46,6 +46,7 @@ const Header = React.createClass({ +