Javascript Factories for Tests
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 item = { | |
type: 'something', | |
age: 23, | |
person: { | |
name: 'Michael' | |
} | |
} | |
const createItem = params => ({...item, ...params}) | |
// default item with some expected attr set that can be reused | |
const itemWithBall = createItem({type: 'ball'}) | |
// factory function to create itemWithBall with other params for other attrs | |
const createBallItem = params => ({...itemWithBall, ...params}) | |
console.log(createBallItem({age: 245})) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment