How to use the ember-cli-mirage.faker.random 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 / levant / vendor / github.com / hashicorp / nomad / ui / mirage / factories / node.js View on Github external
drain: true,
    schedulingEligibility: 'ineligible',
    drainStrategy: {
      Deadline: -1,
      ForceDeadline: '0001-01-01T00:00:00Z',
      IgnoreSystemJobs: faker.random.boolean(),
    },
  }),

  noDeadlineDraining: trait({
    drain: true,
    schedulingEligibility: 'ineligible',
    drainStrategy: {
      Deadline: 0,
      ForceDeadline: '0001-01-01T00:00:00Z',
      IgnoreSystemJobs: faker.random.boolean(),
    },
  }),

  drainStrategy: null,

  drivers: makeDrivers,

  resources: generateResources,

  attributes() {
    // TODO add variability to these
    return {
      'os.version': '10.12.5',
      'cpu.modelname': 'Intel(R) Core(TM) i7-3615QM CPU @ 2.30GHz',
      'nomad.revision': 'f551dcb83e3ac144c9dbb90583b6e82d234662e9',
      'driver.docker.volumes.enabled': '1',
github hashicorp / levant / vendor / github.com / hashicorp / nomad / ui / mirage / factories / allocation.js View on Github external
import Ember from 'ember';
import moment from 'moment';
import { Factory, faker, trait } from 'ember-cli-mirage';
import { provide, pickOne } from '../utils';

const UUIDS = provide(100, faker.random.uuid.bind(faker.random));
const CLIENT_STATUSES = ['pending', 'running', 'complete', 'failed', 'lost'];
const DESIRED_STATUSES = ['run', 'stop', 'evict'];
const REF_TIME = new Date();

export default Factory.extend({
  id: i => (i >= 100 ? `${UUIDS[i % 100]}-${i}` : UUIDS[i]),

  jobVersion: () => faker.random.number(10),

  modifyIndex: () => faker.random.number({ min: 10, max: 2000 }),
  modifyTime: () => faker.date.past(2 / 365, REF_TIME) * 1000000,

  createIndex: () => faker.random.number({ min: 10, max: 2000 }),
  createTime() {
    return faker.date.past(2 / 365, new Date(this.modifyTime / 1000000)) * 1000000;
  },
github ember-cli / ember-twiddle / mirage / factories / owner.js View on Github external
/**
 * This is a factory definition for an owner
 */
import Mirage, { faker } from 'ember-cli-mirage';

export default Mirage.Factory.extend({
  id: faker.random.number(99999),
  avatar_url() {
    return `https://avatars.githubusercontent.com/u/${this.id}?v=3`;
  },
  gravatar_id: "",
  url() {
    return "https://api.github.com/users/" + this.login;
  },
  html_url() {
    return "https://github.com/" + this.login;
  },
  followers_url() {
    return `https://api.github.com/users/${this.login}/followers`;
  },
  following_url() {
    return `https://api.github.com/users/${this.login}/following{/other_user}`;
  },
github CenterForOpenScience / ember-osf-web / mirage / factories / meeting-submission.ts View on Github external
meetingCategory() {
        return faker.random.arrayElement([
            'poster',
            'talk',
        ]);
    },
    authorName() {
github linkedin / WhereHows / wherehows-web / mirage / factories / flow.js View on Github external
import { Factory, faker } from 'ember-cli-mirage';

export default Factory.extend({
  flow_id: faker.random.number({ min: 1000, max: 9000 }),
  appId: faker.random.number({ min: 10, max: 30 }),
  name: '--recreateRootFolder',
  group: 'targeting-expression-evolution',
  level: 0,
  jobCount: 2,
  created: 1371143981901,
  modified: 1381956064561,
  appCode: faker.list.random('AZKABAN PROD WAR', 'LTX1-HOLDEMAZ01')
});
github linkedin / WhereHows / wherehows-web / mirage / factories / dataset.ts View on Github external
import { Factory, faker, trait } from 'ember-cli-mirage';
import { testSchemaA } from 'wherehows-web/mirage/fixtures/schema';

export default Factory.extend({
  id: faker.random.number({ min: 10000, max: 20000 }),
  created: null,
  formatedModified: '2017-09-04 10:34:44.0',
  hasSchemaHistory: false,
  hdfsBrowserLink: null,
  isFavorite: false,
  isOwned: false,
  isWatched: false,
  modified: faker.date.past(),
  name: faker.commerce.productName(),
  properties: () => ({
    DB_ID: faker.random.number({ min: 10000, max: 20000 }),
    TBL_ID: faker.random.number({ min: 10000, max: 20000 }),
    view_depends_on: [faker.commerce.productName()],
    create_time: faker.date.past(),
    etl_source: 'COLUMN_V2',
    input_format: faker.commerce.productName(),
github exercism / gui / mirage / config.js View on Github external
this.post('user/assignments', (schema, request) => {
    const attrs = JSON.parse(request.requestBody);
    if (attrs.language === 'bash') {
      return new Response(400, {}, { error: 'duplicate of previous iteration' });
    }
    if (attrs.language === 'perl6') {
      return new Response(500, {}, { errors: ['some error'] });
    }
    let id = faker.random.uuid(),
        submissionPath = `submissions/${id}`;
    let data = {
      id,
      iteration: faker.random.number({ min: 1, max: 25 }),
      status: 'saved',
      slug: attrs.problem,
      track: attrs.language,
      exercise: attrs.problem,
      track_id: attrs.language,
      submission_path: `/${submissionPath}`,
      url: `http://exercism.io/${submissionPath}`,
      language: Ember.String.capitalize(attrs.language),
      name: Ember.String.capitalize(attrs.problem),
    };
    return new Response(201, {}, data);
  });
}
github CenterForOpenScience / ember-osf-web / mirage / factories / comment.ts View on Github external
afterCreate(comment, server) {
            const siblings = server.schema.comments.where({ targetID: comment.targetID });
            const count = faker.random.number({ min: 0, max: siblings.length - 1 });

            server.createList(
                'comment',
                count,
                { node: comment.node, targetID: comment.id, targetType: 'comments' },
                'withReplies',
            );

            if (count) {
                comment.update({
                    hasChildren: true,
                });
            }
        },
    }),