當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript ember-cli-mirage.Factory類代碼示例

本文整理匯總了TypeScript中ember-cli-mirage.Factory的典型用法代碼示例。如果您正苦於以下問題:TypeScript Factory類的具體用法?TypeScript Factory怎麽用?TypeScript Factory使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了Factory類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: purgeNote

import { Factory, faker } from 'ember-cli-mirage';
import { PurgePolicy } from 'wherehows-web/constants';
import { hdfsUrn, nonHdfsUrn } from 'wherehows-web/mirage/fixtures/urn';

export default Factory.extend({
  datasetId: null,

  datasetUrn: faker.list.random(hdfsUrn, nonHdfsUrn),

  purgeType: faker.list.random(...Object.values(PurgePolicy)),

  purgeNote() {
    const { purgeType } = this;
    return purgeType === PurgePolicy.PurgeExempt ? faker.lorem.words(5) : '';
  },

  modifiedBy: faker.internet.userName(),

  modifiedTime: faker.date.past()
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:20,代碼來源:retention.ts

示例2:

import { Factory, faker } from 'ember-cli-mirage';
import { DatasetPlatform, PurgePolicy } from 'wherehows-web/constants';

export default Factory.extend({
  name: faker.list.random(...Object.values(DatasetPlatform)),

  type: faker.lorem.words(1),

  supportedPurgePolicies: Object.values(PurgePolicy)
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:10,代碼來源:platform.ts

示例3: id

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<IHealthScoreObject> = [];

    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'
      };

      validations.push(validation);
    }

    return validations;
  },

  forTesting: trait({
    score: 83,
    validations() {
      const validations: Array<IHealthScoreObject> = [];

      for (let i = 0; i < 3; i++) {
        const validation: IHealthScoreObject = {
          tier: tierOptions[i],
          score: 1 - (3 - i) * 0.25,
          description: faker.lorem.sentences(2),
          weight: faker.random.number({ min: 0, max: 100 }) / 100,
          validator: 'fake'
        };

        validations.push(validation);
      }
    }
  })
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:43,代碼來源:health.ts

示例4: trait

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(),
    output_format: faker.commerce.productName(),
    is_compressed: false,
    SD_ID: faker.random.number({ min: 10000, max: 20000 }),
    is_storedassubdirectories: false,
    serialization_format: 'Sequence',
    tbl_type: 'VIRTUAL_VIEW',
    view_expanded_text: faker.lorem.sentence()
  }),

  // TODO https://github.com/samselikoff/ember-cli-mirage/issues/1379
  whSchema: 'abcd',
  source: 'Hive',
  urn: faker.internet.url(),
  watchId: 0,
  owners: () => [],

  forUnitTests: trait({
    id(id: number) {
      return id;
    },

    // TODO https://github.com/samselikoff/ember-cli-mirage/issues/1379
    whSchema(id: number) {
      return id === 0 ? testSchemaA : 'abcd';
    }
  }),

  // TODO https://github.com/samselikoff/ember-cli-mirage/issues/1379
  afterCreate(dataset: any) {
    dataset.attrs.schema = dataset.attrs.whSchema;
  }
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:50,代碼來源:dataset.ts

示例5: uri

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
      : nonHdfsUrn.replace(/li:dataPlatform:db/, `li:dataPlatform:${platform}`);
  }
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:24,代碼來源:dataset-view.ts

示例6: userName

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() {
    return faker.random.number({ min: 1, max: 10 });
  }
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:22,代碼來源:owner.ts

示例7: count

import { Factory, faker } from 'ember-cli-mirage';

export default Factory.extend({
  count() {
    return faker.random.number({ min: 0, max: 10000 });
  }
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:7,代碼來源:datasets-count.ts

示例8: containsUserActionGeneratedContent

import { Factory } from 'ember-cli-mirage';

const randomize = () => Math.random() < 0.5;

export default Factory.extend({
  containsUserActionGeneratedContent() {
    return this.randomized ? randomize() : false;
  },

  containsUserDerivedContent() {
    return this.randomized ? randomize() : false;
  },

  containsUserGeneratedContent() {
    return this.randomized ? randomize() : false;
  }
});
開發者ID:alyiwang,項目名稱:WhereHows,代碼行數:17,代碼來源:export-policy.ts


注:本文中的ember-cli-mirage.Factory類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。