How to use the ember-cli-mirage.Factory.extend 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 hashicorp / nomad / ui / mirage / factories / csi-plugin.js View on Github external
import { Factory } from 'ember-cli-mirage';
import faker from 'nomad-ui/mirage/faker';
import { STORAGE_PROVIDERS } from '../common';

export default Factory.extend({
  id: () => faker.random.uuid(),

  // Topologies is currently unused by the UI. This should
  // eventually become dynamic.
  topologies: () => [{ foo: 'bar' }],

  provider: faker.helpers.randomize(STORAGE_PROVIDERS),
  version: '1.0.1',

  controllerRequired: faker.random.boolean,

  controllersHealthy() {
    if (!this.controllerRequired) return 0;
    return faker.random.number(3);
  },
  controllersExpected() {
github elwayman02 / ember-data-github / mirage-support / factories / github-member.js View on Github external
import { Factory } from 'ember-cli-mirage';

export default Factory.extend({
  login: function(i) {
    return `member${i}`;
  },
  type: 'github-member',
  avatar_url: function(i) {
    return `member${i}-avatar.gif`;
  },
  gravatar_id: '',
  site_admin: false,
  url: function(i) {
    return `https://api.github.com/users/member${i}`;
  }
});
github ilios / frontend / mirage / factories / session-description.js View on Github external
import { Factory } from 'ember-cli-mirage';

export default Factory.extend({
  description: (i) => `session description ${i}`,
});
github linkedin / WhereHows / wherehows-web / mirage / factories / owner.ts View on Github external
import { Factory, faker } from 'ember-cli-mirage';

export default Factory.extend({
  userName() {
    return faker.internet.userName();
  },
  departmentNum() {
    return 0;
  },
  email() {
    return faker.internet.email();
  },
  name() {
    return faker.name.firstName() + ' ' + faker.name.lastName();
  },
  userSetting() {
    return null;
  },
  flowId() {
github ember-learn / ember-help-wanted / mirage / factories / issue.js View on Github external
import { Factory, faker } from 'ember-cli-mirage';

export default Factory.extend({
  githubId(i) {
    return `github-issue-${i}`;
  },
  number(i) {
    return `${i + 3000}`;
  },
  org: () => faker.random.arrayElement(['ember-cli', 'emberjs', 'ember-learn']),
  repo: () => faker.random.arrayElement(['ember.js', 'guides', 'ember-cli', 'data']),
  state: () => faker.random.arrayElement(['open', 'closed']),
  title: faker.hacker.phrase,

  createdAt: faker.date.recent,
  updatedAt: faker.date.recent
});
github linkedin / WhereHows / wherehows-web / mirage / factories / health.ts View on Github external
import { Factory, faker, trait } from 'ember-cli-mirage';
import { IHealthScoreObject } from 'wherehows-web/typings/api/datasets/health';

const tierOptions = ['CRITICAL', 'WARNING', 'MINOR'];

export default Factory.extend({
  id(id: number) {
    return id;
  },
  score: faker.random.number({ min: 0, max: 100 }),
  validations() {
    const numValidations = faker.random.number({ min: 1, max: 6 });
    const validations: Array = [];

    for (let i = 0; i < numValidations; i++) {
      const validation: IHealthScoreObject = {
        tier: tierOptions[i % 3],
        score: faker.random.number({ min: 0, max: 100 }) / 100,
        description: faker.lorem.sentences(),
        weight: faker.random.number({ min: 0, max: 100 }) / 100,
        validator: 'fake'
      };
github linkedin / WhereHows / wherehows-web / mirage / factories / dataset-view.ts View on Github external
import { Factory, faker } from 'ember-cli-mirage';
import { DatasetPlatform } from 'wherehows-web/constants';
import { hdfsUrn, nonHdfsUrn } from 'wherehows-web/mirage/fixtures/urn';

export default Factory.extend({
  createdTime: faker.date.past(2),
  deprecated: true,
  deprecationNote: faker.lorem.words(5),
  description: faker.lorem.words(7),
  fabric: null,
  modifiedTime: faker.date.recent(),
  nativeName: 'abook.default-public-container',
  nativeType: null,
  platform: faker.list.random(...Object.values(DatasetPlatform)),
  properties: '{}',
  removed: faker.random.boolean(),
  tags: null,
  uri() {
    const { platform } = this;
    return platform === DatasetPlatform.HDFS
      ? hdfsUrn
github linkedin / WhereHows / wherehows-web / mirage / factories / compliance-suggestion.js View on Github external
const { idIds, nonIdIds } = Object.keys(fieldIdentifierTypes).reduce(
  ({ idIds, nonIdIds }, fieldIdTypeKey) => {
    const fieldIdentifier = fieldIdentifierTypes[fieldIdTypeKey].value;
    if (fieldIdentifierTypes[fieldIdTypeKey].isId) {
      idIds = [...idIds, fieldIdentifier];
    } else {
      nonIdIds = [...nonIdIds, fieldIdentifier];
    }

    return { idIds, nonIdIds };
  },
  { idIds: [], nonIdIds: [] }
);

export default Factory.extend({
  fieldName: "address[type='com.linkedin.common.MultiLocaleString']",

  identifierTypePrediction: {
    value: (i) => {
      const fieldIdentifierIsId = i % 2;
      return faker.list.random(...(fieldIdentifierIsId ? idIds : nonIdIds))();
    },
    confidence: Math.random()
  },

  logicalTypePrediction: {
    value: (i) => {
      const fieldIdentifierIsId = i % 2;
      const idArray = [...idLogicalTypes, ...customIdLogicalTypes];
      return faker.list.random(...(fieldIdentifierIsId ? idArray : Object.keys(nonIdFieldLogicalTypes)))();
    },