This file contains 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
{ | |
... | |
"detox": { | |
- "test-runner": "jest" | |
+ "test-runner": "jest", | |
+ "configurations": { | |
+ "ios.sim": { | |
+ "binaryPath": "bin/Exponent.app", | |
+ "type": "ios.simulator", | |
+ "name": "iPhone 8" |
This file contains 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
+const { reloadApp } = require('detox-expo-helpers'); | |
+ | |
describe('Example', () => { | |
beforeEach(async () => { | |
- await device.reloadReactNative(); | |
+ await reloadApp(); | |
}); |
This file contains 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
"android": "expo start --android", | |
"ios": "expo start --ios", | |
+ "test": "node_modules/.bin/jest test/**/*.spec.js", | |
"eject": "expo eject" | |
}, | |
... | |
"jest-expo": "^31.0.0" | |
}, | |
+ "jest": { | |
+ "preset": "jest-expo" |
This file contains 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 from 'react'; | |
import { | |
FlatList, | |
Text, | |
} from 'react-native'; | |
const MessageList = ({ data }) => ( | |
<FlatList | |
data={data} | |
keyExtractor={item => item} |
This file contains 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 NewMessageForm from './NewMessageForm'; | |
+import MessageList from './MessageList'; | |
... | |
render() { | |
+ const { messages } = this.state; | |
return ( | |
<View> | |
<NewMessageForm onSend={this.handleSend} /> | |
+ <MessageList data={messages} /> |
This file contains 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
export default class App extends Component { | |
+ state = { messages: [] } | |
+ | |
handleSend = (newMessage) => { | |
+ this.setState(state => ({ messages: [newMessage, ...state.messages] })); | |
} |
This file contains 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
export default class App extends Component { | |
+ handleSend = (newMessage) => { | |
+ } | |
+ | |
render() { | |
return ( | |
<View> | |
- <NewMessageForm /> | |
+ <NewMessageForm onSend={this.handleSend} /> | |
</View> |
This file contains 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
handleSend = () => { | |
+ const { inputText } = this.state; | |
+ const { onSend } = this.props; | |
+ | |
+ onSend(inputText); | |
+ | |
this.setState({ inputText: '' }); | |
} |
This file contains 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
describe('clicking send', () => { | |
const messageText = 'Hello world'; | |
+ let sendHandler; | |
let getByTestId; | |
beforeEach(() => { | |
+ sendHandler = jest.fn(); | |
- ({ getByTestId } = render(<NewMessageForm />)); |
This file contains 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
export default class NewMessageForm extends Component { | |
state = { inputText: '' } | |
handleChangeText = (text) => { | |
this.setState({ inputText: text }); | |
} | |
+ handleSend = () => { | |
+ this.setState({ inputText: '' }); | |
+ } |