Ghost/ghost/admin/mirage/factories/offer.js
Kevin Ansfield c4c48d4104 Resolved ember-cli-mirage import deprecations
refs https://github.com/TryGhost/Admin/pull/2209

- `miragejs` has been extracted to a framework-independent library, the re-exports of `miragejs` elements in `ember-cli-mirage` have been deprecated making our test logs very noisy
- added `miragejs` as a top-level dependency
- updated all relevant imports to pull from `miragejs` instead of `ember-cli-mirage`
2022-03-08 11:32:01 +00:00

21 lines
673 B
JavaScript

import faker from 'faker';
import moment from 'moment';
import {Factory} from 'miragejs';
let randomDate = function randomDate(start = moment().subtract(30, 'days').toDate(), end = new Date()) {
return new Date(start.getTime() + Math.random() * (end.getTime() - start.getTime()));
};
export default Factory.extend({
name() { return `${faker.name.firstName()} ${faker.name.lastName()}`; },
amount() { return faker.datatype.number({min: 1, max: 10}); },
displayTitle() { return faker.lorem.word(); },
code() { return faker.lorem.slug(); },
createdAt() { return randomDate(); },
tier() {
return {
id: '1'
};
}
});