Skip to content

Instantly share code, notes, and snippets.

@ryanflorence
Last active September 25, 2017 23:29
Show Gist options
  • Save ryanflorence/84a4708e532c8250ef4e3fc995f19b28 to your computer and use it in GitHub Desktop.
Save ryanflorence/84a4708e532c8250ef4e3fc995f19b28 to your computer and use it in GitHub Desktop.
it('passes expenses in', (done) => {
const fakeExpenses = [ ... ]
fakeNetwork('/expenses', fakeExpenses)
render(<Expenses render={(expenses) => {
expect(expenses).toBe(fakeExpenses)
}}/>, done)
})
// But you probably weren't even testing the "container" component that this
// replaces :O
// if you want to still have a "container" v. "view" split and only test the
// "views" like you currently do, use it like this in the App:
const Expenses = () => (
// here's your old container HOC
<ExpensesContainer render={(expenses) => (
// Here's your old "view"
<ExpensesView expenses={expenses}/>
)}/>
)
export default Expenses
export ExpensesView
// And then only test ExpensesView just like before, but with render props,
// there's not usually a file that exports both of these, the coupling usually
// goes away. It's one of those questions that gets eliminated.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment