How to use the ember-cli-mirage.association function in ember-cli-mirage

To help you get started, we’ve selected a few ember-cli-mirage examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github gothinkster / ember-realworld / mirage / factories / comment.js View on Github external
import { Factory, association } from 'ember-cli-mirage';
import faker from 'faker';

export default Factory.extend({
  author: association(),
  article: association(),

  createdAt() {
    return faker.date.recent();
  },

  updatedAt() {
    return faker.date.recent();
  },

  body() {
    return faker.lorem.paragraphs();
  },
});
github CenterForOpenScience / ember-osf-web / mirage / factories / user.ts View on Github external
return faker.name.lastName();
    },
    suffix() {
        return faker.name.suffix();
    },
    locale() {
        return 'en_US';
    },
    active: true,
    timezone() {
        return 'America/New_York';
    },
    acceptedTermsOfService: true,
    canViewReviews: false,
    social: {},
    defaultRegion: association(),
    dateRegistered() {
        return faker.date.past(2, new Date(2018, 0, 0));
    },

    withFiles: trait({
        afterCreate(user, server) {
            server.createList('file', 5, { user });
        },
    }),

    withInstitutions: trait({
        afterCreate(user, server) {
            server.createList('institution', 3, { users: [user] });
        },
    }),