|
1 | 1 | import React from 'react'; |
2 | | -import { Button, Image, Text, TextInput } from 'react-native'; |
| 2 | +import { Button, Image, Text, TextInput, TouchableHighlight } from 'react-native'; |
3 | 3 |
|
4 | 4 | import { render, fireEvent } from '../'; |
5 | 5 | import { NativeEvent } from '../events'; |
@@ -55,13 +55,24 @@ test('calling a handler when there is no valid target throws', () => { |
55 | 55 | expect(handleEvent).toBeCalledTimes(0); |
56 | 56 | }); |
57 | 57 |
|
58 | | -test('calling a handler the target is disabled throws', () => { |
| 58 | +test('calling a handler if a Button is disabled throws', () => { |
59 | 59 | const handleEvent = jest.fn(); |
60 | 60 | const { getByText } = render(<Button disabled onPress={handleEvent} title="button" />); |
61 | 61 | expect(() => fireEvent.press(getByText('button'))).toThrow(); |
62 | 62 | expect(handleEvent).toBeCalledTimes(0); |
63 | 63 | }); |
64 | 64 |
|
| 65 | +test('calling a handler if a Touchable is disabled throws', () => { |
| 66 | + const handleEvent = jest.fn(); |
| 67 | + const { getByText } = render( |
| 68 | + <TouchableHighlight disabled onPress={jest.fn()}> |
| 69 | + <Text>touchable</Text> |
| 70 | + </TouchableHighlight> |
| 71 | + ); |
| 72 | + expect(() => fireEvent.press(getByText('touchable'))).toThrow(); |
| 73 | + expect(handleEvent).toBeCalledTimes(0); |
| 74 | +}); |
| 75 | + |
65 | 76 | test('calling an event that has no defined handler throws', () => { |
66 | 77 | const { getByText } = render(<Text>test</Text>); |
67 | 78 | expect(() => fireEvent.press(getByText('test'))).toThrow(); |
|
0 commit comments