2019-10-03 14:13:08 +00:00
|
|
|
import faker from 'faker';
|
|
|
|
import config from 'nomad-ui/config/environment';
|
|
|
|
|
|
|
|
const searchIncludesSeed = window.location.search.includes('faker-seed');
|
|
|
|
|
|
|
|
if (config.environment !== 'test' || searchIncludesSeed) {
|
|
|
|
if (searchIncludesSeed) {
|
|
|
|
const params = new URLSearchParams(window.location.search);
|
|
|
|
const seed = parseInt(params.get('faker-seed'));
|
|
|
|
faker.seed(seed);
|
|
|
|
} else {
|
|
|
|
faker.seed(1);
|
|
|
|
}
|
2020-10-22 18:45:51 +00:00
|
|
|
} else if (config.environment === 'test') {
|
|
|
|
const randomSeed = faker.random.number();
|
2020-10-29 12:46:42 +00:00
|
|
|
console.log(
|
|
|
|
`No seed specified with faker-seed query parameter, seeding Faker with ${randomSeed}`
|
|
|
|
);
|
2020-10-22 18:45:51 +00:00
|
|
|
faker.seed(randomSeed);
|
2019-10-03 14:13:08 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
export default faker;
|