Last active
March 5, 2018 10:34
-
-
Save innerdaze/14a6997c852235bf1b7ce77692861f73 to your computer and use it in GitHub Desktop.
Using Faker & Ramda to generate fixtures
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 faker from 'faker' | |
import { compose, map, applySpec, always } from 'ramda' | |
/** | |
* Usage: | |
* | |
* import { generateWastage, generateWastageArray } from './fixtures | |
* | |
* const wastageFixture = generateWastage() | |
* const wastageFixtures = generateWastageArray(3) | |
*/ | |
// Wastage | |
export const wastageModel = { | |
_id: faker.random.uuid, | |
ProductID: faker.random.alphaNumeric, | |
WastageType: faker.random.number, | |
Qty: faker.random.number | |
} | |
export const generateWastage = applySpec(wastageModel) | |
export const generateWastageArray = compose(map(generateWastage), Array) | |
// WastageType | |
export const wastageTypeModel = { | |
__type: always('WastageType'), | |
Name: faker.random.word, | |
TypeID: faker.random.alphaNumeric | |
} | |
export const generateWastageType = applySpec(wastageTypeModel) | |
export const generateWastageTypeArray = compose(map(generateWastageType), Array) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment