open-nomad/ui/mirage/faker.js
Buck Doyle 31b4ed7a6d
Add DAS UI code from enterprise (#9192)
This is a few combined iterations on the DAS feature.
2020-10-29 07:46:42 -05:00

23 lines
662 B
JavaScript

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);
}
} else if (config.environment === 'test') {
const randomSeed = faker.random.number();
console.log(
`No seed specified with faker-seed query parameter, seeding Faker with ${randomSeed}`
);
faker.seed(randomSeed);
}
export default faker;