Last active
September 13, 2019 13:25
-
-
Save overengineered/5e6670be328577861ce8acb1c6bedd08 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import 'react-native'; | |
import {act} from 'react-test-renderer'; | |
import {componentDriver} from 'react-component-driver'; | |
import Example from '../App'; | |
const getExampleDriver = () => componentDriver(Example, { | |
toggleAwesome(value) { | |
this.getByID('awesome').props.onValueChange(value); | |
return this; | |
}, | |
pressSend() { | |
this.getByID('submit').props.onPress(); | |
return this; | |
}, | |
isAwesome() { | |
return this.getByID('awesome').props.value; | |
}, | |
}); | |
test('using Example screen driver', async () => { | |
fetch = jest.fn(); | |
const driver = getExampleDriver() | |
.toggleAwesome(true) | |
.pressSend(); | |
expect(driver.isAwesome()).toBeTruthy(); | |
expect(fetch).toHaveBeenCalledTimes(1); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment