From 1716b6736fed674464d05be134072482dad5defc Mon Sep 17 00:00:00 2001 From: Nathan Hunzaker Date: Tue, 11 Jul 2017 07:51:00 -0400 Subject: [PATCH] Add test fixtures to cover disabled selected options --- fixtures/dom/src/components/IssueList.js | 26 ++++++ fixtures/dom/src/components/TestCase.js | 11 ++- .../src/components/fixtures/selects/index.js | 84 ++++++++++++++----- fixtures/dom/src/style.css | 20 +++-- 4 files changed, 112 insertions(+), 29 deletions(-) create mode 100644 fixtures/dom/src/components/IssueList.js diff --git a/fixtures/dom/src/components/IssueList.js b/fixtures/dom/src/components/IssueList.js new file mode 100644 index 0000000000000..e1b31c89c8111 --- /dev/null +++ b/fixtures/dom/src/components/IssueList.js @@ -0,0 +1,26 @@ +const React = window.React; + +function csv(string) { + return string.split(/\s*,\s*/); +} + +export default function IssueList ({ issues }) { + if (!issues) { + return null; + } + + if (typeof issues === 'string') { + issues = csv(issues); + } + + let links = issues.reduce((memo, issue, i) => { + return memo.concat( + i > 0 && i < issues.length ? ', ' : null, + + {issue} + + ); + }, []); + + return {links}; +} diff --git a/fixtures/dom/src/components/TestCase.js b/fixtures/dom/src/components/TestCase.js index 053eac9467884..3ace9d31f1f53 100644 --- a/fixtures/dom/src/components/TestCase.js +++ b/fixtures/dom/src/components/TestCase.js @@ -1,7 +1,9 @@ +const React = window.React; + import cn from 'classnames'; import semver from 'semver'; -import React from 'react'; import PropTypes from 'prop-types'; +import IssueList from './IssueList'; import { parse } from 'query-string'; import { semverString } from './propTypes'; @@ -34,6 +36,7 @@ class TestCase extends React.Component { resolvedIn, resolvedBy, affectedBrowsers, + relatedIssues, children, } = this.props; @@ -93,6 +96,12 @@ class TestCase extends React.Component { {affectedBrowsers &&
{affectedBrowsers}
} + + {relatedIssues && +
Related Issues:
} + {relatedIssues && +
+ }

diff --git a/fixtures/dom/src/components/fixtures/selects/index.js b/fixtures/dom/src/components/fixtures/selects/index.js index a520e40c3b92f..1ebfacf5f7590 100644 --- a/fixtures/dom/src/components/fixtures/selects/index.js +++ b/fixtures/dom/src/components/fixtures/selects/index.js @@ -1,5 +1,8 @@ const React = window.React; +import FixtureSet from '../../FixtureSet'; +import TestCase from '../../TestCase'; + class SelectFixture extends React.Component { state = { value: '' }; onChange = (event) => { @@ -7,27 +10,66 @@ class SelectFixture extends React.Component { } render() { return ( -

-
- Controlled - - Value: {this.state.value} -
-
- Uncontrolled - -
-
+ +
+
+ Controlled + + Value: {this.state.value} +
+
+ Uncontrolled + +
+
+ + + +
  • Open the select
  • +
  • Select "1"
  • +
  • Attempt to reselect "Please select an item"
  • +
    + + + The initial picked option should be "Please select an + item", however it should not be a selectable option. + + +
    + +
    +
    + + + + The initial picked option value should "0": the first non-disabled option. + + +
    + +
    +
    +
    ); } } diff --git a/fixtures/dom/src/style.css b/fixtures/dom/src/style.css index cb38d9e0fffa5..28e01b611b2fe 100644 --- a/fixtures/dom/src/style.css +++ b/fixtures/dom/src/style.css @@ -8,23 +8,20 @@ html { font-size: 10px; } body { - font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", sans-serif; + font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", "Roboto", "Oxygen", + "Ubuntu", "Cantarell", "Fira Sans", "Droid Sans", "Helvetica Neue", + sans-serif; font-size: 1.4rem; margin: 0; padding: 0; } -select { - width: 12rem; -} - button { margin: 10px; font-size: 18px; padding: 5px; } - .header { background: #222; box-shadow: inset 0 -1px 3px #000; @@ -34,6 +31,10 @@ button { padding: .8rem 1.6rem; } +.header select { + width: 12rem; +} + .header__inner { display: table; margin: 0 auto; @@ -101,7 +102,8 @@ fieldset { overflow: hidden; } -ul, ol { +ul, +ol { margin: 0 0 2rem 0; } @@ -212,3 +214,7 @@ li { background-color: #f4f4f4; border-top: 1px solid #d9d9d9; } + +.field-group { + overflow: hidden; +}