Skip to content

Instantly share code, notes, and snippets.

@kbingman
Created October 18, 2019 23:23
Show Gist options
  • Save kbingman/eb11db773478e6cf88ef290f78e70cb6 to your computer and use it in GitHub Desktop.
Save kbingman/eb11db773478e6cf88ef290f78e70cb6 to your computer and use it in GitHub Desktop.
Fake Listing
import faker from 'faker';
import { makes } from '../../../../test/makes';
import { Listing } from '../../src/types';
faker.seed(42);
export const createFakeListing = (attr?: any): Listing => {
const [make, model] = makes[faker.random.number(makes.length)];
return {
uuid: faker.random.uuid(),
hash: faker.random.hexaDecimal(6),
title: faker.lorem.sentence(),
url: faker.internet.url(),
year: faker.random.number({ min: 1960, max: 1974 }),
created: (faker.date.between(new Date('2019-08-01'), new Date())).toString(),
make,
model,
price: faker.random.number({ min: 1000, max: 100000 }),
...attr
};
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment