mirror of
https://github.com/zhigang1992/react-native-web.git
synced 2026-04-29 12:54:53 +08:00
Fix unreliable TextInput tests
This commit is contained in:
@@ -97,17 +97,14 @@ suite('components/TextInput', () => {
|
|||||||
return str
|
return str
|
||||||
}
|
}
|
||||||
|
|
||||||
let input = findInput(utils.renderAndInject(
|
const result = utils.shallowRender(
|
||||||
<TextInput
|
<TextInput
|
||||||
maxNumberOfLines={3}
|
maxNumberOfLines={3}
|
||||||
multiline
|
multiline
|
||||||
value={generateValue()}
|
value={generateValue()}
|
||||||
/>
|
/>
|
||||||
))
|
)
|
||||||
const height = input.getBoundingClientRect().height
|
assert.equal(findShallowInput(result).props.maxRows, 3)
|
||||||
// need a range because of cross-browser differences
|
|
||||||
assert.ok(height >= 42, height)
|
|
||||||
assert.ok(height <= 48, height)
|
|
||||||
})
|
})
|
||||||
|
|
||||||
test('prop "multiline"', () => {
|
test('prop "multiline"', () => {
|
||||||
@@ -126,10 +123,14 @@ suite('components/TextInput', () => {
|
|||||||
// with multiline
|
// with multiline
|
||||||
input = findInput(utils.renderAndInject(<TextInput multiline numberOfLines={2} />))
|
input = findInput(utils.renderAndInject(<TextInput multiline numberOfLines={2} />))
|
||||||
assert.equal(input.tagName, 'TEXTAREA')
|
assert.equal(input.tagName, 'TEXTAREA')
|
||||||
const height = input.getBoundingClientRect().height
|
|
||||||
// need a range because of cross-browser differences
|
const result = utils.shallowRender(
|
||||||
assert.ok(height >= 30, height)
|
<TextInput
|
||||||
assert.ok(height <= 36, height)
|
multiline
|
||||||
|
numberOfLines={3}
|
||||||
|
/>
|
||||||
|
)
|
||||||
|
assert.equal(findShallowInput(result).props.minRows, 3)
|
||||||
})
|
})
|
||||||
|
|
||||||
test('prop "onBlur"', (done) => {
|
test('prop "onBlur"', (done) => {
|
||||||
|
|||||||
Reference in New Issue
Block a user