Created
April 20, 2017 15:14
-
-
Save amite/ff43a9981f809a1a847efdee47691819 to your computer and use it in GitHub Desktop.
Faker Factories
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
let faker = require('faker') | |
const getRandom = (arr) => arr[Math.floor(Math.random()*arr.length)] | |
const createCombos = (foodNames, foodTypes) => foodNames.map( (item, index) => `${getRandom(foodTypes)} ${item}`) | |
const foodNames = ['Samosa', 'Sandwich', 'Roll', 'Pattice'] | |
const foodTypes = ['Non Veg', 'Veg', 'Jain'] | |
function Combo() { | |
return { | |
contents: createCombos(foodNames, foodTypes), | |
price: faker.commerce.price(), | |
} | |
} | |
const make = (num = 5) => fn => Array.from({length: num}, fn); | |
let fakeComboFactory = make(30) | |
// console.log(fakeUsers) | |
let combos = fakeComboFactory(Combo) | |
// console.clear() | |
console.log(combos) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment