|
| 1 | +const React = window.React; |
| 2 | + |
| 3 | +import FixtureSet from '../../FixtureSet'; |
| 4 | +import TestCase from '../../TestCase'; |
| 5 | +import NumberTestCase from './NumberTestCase'; |
| 6 | + |
| 7 | +const NumberInputs = React.createClass({ |
| 8 | + render() { |
| 9 | + return ( |
| 10 | + <FixtureSet |
| 11 | + title="Number inputs" |
| 12 | + description="Number inputs inconsistently assign and report the value |
| 13 | + property depending on the browser." |
| 14 | + > |
| 15 | + <TestCase |
| 16 | + title="Backspacing" |
| 17 | + description="The decimal place should not be lost" |
| 18 | + > |
| 19 | + <TestCase.Steps> |
| 20 | + <li>Type "3.1"</li> |
| 21 | + <li>Press backspace, eliminating the "1"</li> |
| 22 | + </TestCase.Steps> |
| 23 | + |
| 24 | + <TestCase.ExpectedResult> |
| 25 | + The field should read "3.", preserving the decimal place |
| 26 | + </TestCase.ExpectedResult> |
| 27 | + |
| 28 | + <NumberTestCase /> |
| 29 | + |
| 30 | + <p className="footnote"> |
| 31 | + <b>Notes:</b> Chrome and Safari clear trailing |
| 32 | + decimals on blur. React makes this concession so that the |
| 33 | + value attribute remains in sync with the value property. |
| 34 | + </p> |
| 35 | + </TestCase> |
| 36 | + |
| 37 | + <TestCase |
| 38 | + title="Decimal precision" |
| 39 | + description="Supports decimal precision greater than 2 places" |
| 40 | + > |
| 41 | + <TestCase.Steps> |
| 42 | + <li>Type "0.01"</li> |
| 43 | + </TestCase.Steps> |
| 44 | + |
| 45 | + <TestCase.ExpectedResult> |
| 46 | + The field should read "0.01" |
| 47 | + </TestCase.ExpectedResult> |
| 48 | + |
| 49 | + <NumberTestCase /> |
| 50 | + </TestCase> |
| 51 | + |
| 52 | + <TestCase |
| 53 | + title="Exponent form" |
| 54 | + description="Supports exponent form ('2e4')" |
| 55 | + > |
| 56 | + <TestCase.Steps> |
| 57 | + <li>Type "2e"</li> |
| 58 | + <li>Type 4, to read "2e4"</li> |
| 59 | + </TestCase.Steps> |
| 60 | + |
| 61 | + <TestCase.ExpectedResult> |
| 62 | + The field should read "2e4". The parsed value should read "20000" |
| 63 | + </TestCase.ExpectedResult> |
| 64 | + |
| 65 | + <NumberTestCase /> |
| 66 | + </TestCase> |
| 67 | + |
| 68 | + <TestCase |
| 69 | + title="Exponent Form" |
| 70 | + description="Pressing 'e' at the end" |
| 71 | + > |
| 72 | + <TestCase.Steps> |
| 73 | + <li>Type "3.14"</li> |
| 74 | + <li>Press "e", so that the input reads "3.14e"</li> |
| 75 | + </TestCase.Steps> |
| 76 | + |
| 77 | + <TestCase.ExpectedResult> |
| 78 | + The field should read "3.14e", the parsed value should be empty |
| 79 | + </TestCase.ExpectedResult> |
| 80 | + |
| 81 | + <NumberTestCase /> |
| 82 | + </TestCase> |
| 83 | + |
| 84 | + <TestCase |
| 85 | + title="Exponent Form" |
| 86 | + description="Supports pressing 'ee' in the middle of a number" |
| 87 | + > |
| 88 | + <TestCase.Steps> |
| 89 | + <li>Type "3.14"</li> |
| 90 | + <li>Move the text cursor to after the decimal place</li> |
| 91 | + <li>Press "e" twice, so that the value reads "3.ee14"</li> |
| 92 | + </TestCase.Steps> |
| 93 | + |
| 94 | + <TestCase.ExpectedResult> |
| 95 | + The field should read "3.ee14" |
| 96 | + </TestCase.ExpectedResult> |
| 97 | + |
| 98 | + <NumberTestCase /> |
| 99 | + </TestCase> |
| 100 | + |
| 101 | + <TestCase |
| 102 | + title="Trailing Zeroes" |
| 103 | + description="Typing '3.0' preserves the trailing zero" |
| 104 | + > |
| 105 | + <TestCase.Steps> |
| 106 | + <li>Type "3.0"</li> |
| 107 | + </TestCase.Steps> |
| 108 | + |
| 109 | + <TestCase.ExpectedResult> |
| 110 | + The field should read "3.0" |
| 111 | + </TestCase.ExpectedResult> |
| 112 | + |
| 113 | + <NumberTestCase /> |
| 114 | + </TestCase> |
| 115 | + |
| 116 | + <TestCase |
| 117 | + title="Inserting decimals precision" |
| 118 | + description="Inserting '.' in to '300' maintains the trailing zeroes" |
| 119 | + > |
| 120 | + <TestCase.Steps> |
| 121 | + <li>Type "300"</li> |
| 122 | + <li>Move the cursor to after the "3"</li> |
| 123 | + <li>Type "."</li> |
| 124 | + </TestCase.Steps> |
| 125 | + |
| 126 | + <TestCase.ExpectedResult> |
| 127 | + The field should read "3.00", not "3" |
| 128 | + </TestCase.ExpectedResult> |
| 129 | + <NumberTestCase /> |
| 130 | + </TestCase> |
| 131 | + |
| 132 | + <TestCase |
| 133 | + title="Replacing numbers with -" |
| 134 | + description="Replacing a number with the '-' sign should not clear the value" |
| 135 | + > |
| 136 | + <TestCase.Steps> |
| 137 | + <li>Type "3"</li> |
| 138 | + <li>Select the entire value"</li> |
| 139 | + <li>Type '-' to replace '3' with '-'</li> |
| 140 | + </TestCase.Steps> |
| 141 | + |
| 142 | + <TestCase.ExpectedResult> |
| 143 | + The field should read "-", not be blank. |
| 144 | + </TestCase.ExpectedResult> |
| 145 | + <NumberTestCase /> |
| 146 | + </TestCase> |
| 147 | + |
| 148 | + <TestCase |
| 149 | + title="Negative numbers" |
| 150 | + description="Typing minus when inserting a negative number should work" |
| 151 | + > |
| 152 | + <TestCase.Steps> |
| 153 | + <li>Type "-"</li> |
| 154 | + <li>Type '3'</li> |
| 155 | + </TestCase.Steps> |
| 156 | + |
| 157 | + <TestCase.ExpectedResult> |
| 158 | + The field should read "-3". |
| 159 | + </TestCase.ExpectedResult> |
| 160 | + <NumberTestCase /> |
| 161 | + </TestCase> |
| 162 | + </FixtureSet> |
| 163 | + ); |
| 164 | + }, |
| 165 | +}); |
| 166 | + |
| 167 | +export default NumberInputs; |
0 commit comments