This commit is contained in:
Nicolas Gallagher
2015-09-20 21:00:15 -07:00
parent ec9985a3b3
commit 39b273f9d8
3 changed files with 13 additions and 20 deletions

View File

@@ -29,30 +29,26 @@ suite('Image', () => {
test('prop "onError"', function (done) { test('prop "onError"', function (done) {
this.timeout(5000) this.timeout(5000)
function onError(e) {
assert.equal(e.nativeEvent.type, 'error')
done()
}
render(<Image render(<Image
onError={onError} onError={onError}
source={{ uri: 'https://google.com/favicon.icox' }} source={{ uri: 'https://google.com/favicon.icox' }}
/>) />)
function onError(e) {
assert.equal(e.nativeEvent.type, 'error')
done()
}
}) })
test('prop "onLoad"', function (done) { test('prop "onLoad"', function (done) {
this.timeout(5000) this.timeout(5000)
function onLoad(e) {
assert.equal(e.nativeEvent.type, 'load')
done()
}
render(<Image render(<Image
onLoad={onLoad} onLoad={onLoad}
source={{ uri: 'https://google.com/favicon.ico' }} source={{ uri: 'https://google.com/favicon.ico' }}
/>) />)
function onLoad(e) {
assert.equal(e.nativeEvent.type, 'load')
done()
}
}) })
test.skip('prop "onLoadEnd"', () => { }) test.skip('prop "onLoadEnd"', () => { })

View File

@@ -18,7 +18,6 @@ suite('Text', () => {
test('prop "children"', () => { test('prop "children"', () => {
const children = 'children' const children = 'children'
const result = shallowRender(<Text>{children}</Text>) const result = shallowRender(<Text>{children}</Text>)
assert.equal(result.props.children, children) assert.equal(result.props.children, children)
}) })
@@ -31,9 +30,7 @@ suite('Text', () => {
test('prop "onPress"', (done) => { test('prop "onPress"', (done) => {
const dom = renderToDOM(<Text onPress={onPress} />) const dom = renderToDOM(<Text onPress={onPress} />)
ReactTestUtils.Simulate.click(dom) ReactTestUtils.Simulate.click(dom)
function onPress(e) { function onPress(e) {
assert(true, 'the "onPress" callback was never called')
assert.ok(e.nativeEvent) assert.ok(e.nativeEvent)
done() done()
} }

View File

@@ -84,11 +84,6 @@ export function render(element, container) {
: ReactTestUtils.renderIntoDocument(element) : ReactTestUtils.renderIntoDocument(element)
} }
export function renderToDOM(element, container) {
const result = render(element, container)
return React.findDOMNode(result)
}
export function renderAndInject(element) { export function renderAndInject(element) {
const id = '_renderAndInject' const id = '_renderAndInject'
let div = document.getElementById(id) let div = document.getElementById(id)
@@ -105,6 +100,11 @@ export function renderAndInject(element) {
return React.findDOMNode(result) return React.findDOMNode(result)
} }
export function renderToDOM(element, container) {
const result = render(element, container)
return React.findDOMNode(result)
}
export function requiresFocus(test, fallback) { export function requiresFocus(test, fallback) {
if (document.hasFocus && document.hasFocus()) { if (document.hasFocus && document.hasFocus()) {
test() test()