当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript chance.integer函数代码示例

本文整理汇总了TypeScript中chance.integer函数的典型用法代码示例。如果您正苦于以下问题:TypeScript integer函数的具体用法?TypeScript integer怎么用?TypeScript integer使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了integer函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: generateNeeds

function generateNeeds(): any {

    let skillIds = Object.keys(store.skillMap);
    let projectIds = Object.keys(store.projectMap);

    let needMap: any = {};

    for (let i = 0; i < 50; i++) {
        let id = nextId++;

        // Set start date to Monday this week + random number of weeks
        var numWeeksAfter = chance.integer({ min: 0, max: 26 });
        var startDate = moment().weekday(1).startOf('day').add(numWeeksAfter, 'weeks');

        // Set duration to a random number of weeks
        var numWeeksDuration = chance.integer({ min: 1, max: 26 });
        var endDate = startDate.clone().add(numWeeksDuration - 1, 'weeks').add(4, 'days').endOf('day');

        needMap[id] = {
            id: id,
            startDate: startDate.toDate(),
            endDate: endDate.toDate(),
            projectId: parseInt(chance.pick(projectIds)),
            skillId: parseInt(chance.pick(skillIds)),
            personId: null,
        };
    };

    return needMap;
}
开发者ID:jbhg,项目名称:staffer,代码行数:30,代码来源:generate-data.ts

示例2: beforeEach

beforeEach(() => {
  config = {
    host: '127.0.0.1',
    maxPayload: new ByteSizeValue(1024),
    port: chance.integer({ min: 10000, max: 15000 }),
    ssl: {
      enabled: true,
      redirectHttpFromPort: chance.integer({ min: 20000, max: 30000 }),
    },
  } as HttpConfig;

  server = new HttpsRedirectServer(loggingServiceMock.create().get());
});
开发者ID:elastic,项目名称:kibana,代码行数:13,代码来源:https_redirect_server.test.ts

示例3: it

  it('should create the specified number of tokens', async () => {
    const numTokens = chance.integer({ min: 1, max: 20 });
    const tokensFromApi = await tokensLib.createEnrollmentTokens(framework.internalUser, numTokens);

    expect(tokensFromApi.length).toEqual(numTokens);
    expect(tokensFromApi).toEqual(tokensDB.map((t: TokenEnrollmentData) => t.token));
  });
开发者ID:salihkardan,项目名称:kibana,代码行数:7,代码来源:tokens.test.ts

示例4:

 const generateRandomContentOutput = () => {
   return {
     address: chance.string(),
     content_type: chance.string(),
     size: chance.integer()
   };
 };
开发者ID:trussle,项目名称:snowy-js-client,代码行数:7,代码来源:contents.spec.ts

示例5: beforeEach

beforeEach(() => {
  config = {
    host: '127.0.0.1',
    maxPayload: new ByteSizeValue(1024),
    port: chance.integer({ min: 10000, max: 15000 }),
    ssl: {},
  } as HttpConfig;

  server = new HttpServer(logger.get());
});
开发者ID:rashidkpc,项目名称:kibana,代码行数:10,代码来源:http_server.test.ts

示例6:

 const generateLedger = (): ILedgerInput => {
   return {
     name: chance.name(),
     author_id: chance.guid(),
     resource_address: chance.guid(),
     resource_content_type: ContentType.OCTETSTREAM,
     resource_size: chance.integer({min: 1, max: 25000}),
     tags: [chance.string(), chance.string()].sort()
   };
 };
开发者ID:trussle,项目名称:snowy-js-client,代码行数:10,代码来源:ledgers.spec.ts

示例7: beforeEach

    beforeEach(async () => {
      validEnrollmentToken = chance.word();
      beatId = chance.word();

      beatsDB = [];
      tagsDB = [];
      tokensDB = [
        {
          expires_on: moment()
            .add(4, 'hours')
            .toJSON(),
          token: validEnrollmentToken,
        },
      ];

      const version =
        chance.integer({ min: 1, max: 10 }) +
        '.' +
        chance.integer({ min: 1, max: 10 }) +
        '.' +
        chance.integer({ min: 1, max: 10 });

      beat = {
        host_name: 'foo.bar.com',
        type: 'filebeat',
        version,
      };

      const framework = new HapiBackendFrameworkAdapter(settings);

      tokensLib = new CMTokensDomain(new MemoryTokensAdapter(tokensDB), {
        framework,
      });

      const tagsLib = new CMTagsDomain(new MemoryTagsAdapter(tagsDB));

      beatsLib = new CMBeatsDomain(new MemoryBeatsAdapter(beatsDB), {
        tags: tagsLib,
        tokens: tokensLib,
        framework,
      });
    });
开发者ID:salihkardan,项目名称:kibana,代码行数:42,代码来源:enroll.test.ts

示例8: test

test('throws if SSL is not enabled', async () => {
  await expect(
    server.start({
      ...config,
      ssl: {
        enabled: false,
        redirectHttpFromPort: chance.integer({ min: 20000, max: 30000 }),
      },
    } as HttpConfig)
  ).rejects.toMatchSnapshot();
});
开发者ID:elastic,项目名称:kibana,代码行数:11,代码来源:https_redirect_server.test.ts

示例9: describe

describe("Ledgers", () => {
  const chance = new Chance();

  const body = {
    name: chance.name(),
    resource_address: chance.string(),
    resource_size: chance.integer({min: 1, max: 25000}),
    resource_content_type: chance.string(),
    author_id: chance.guid(),
    tags: [
      chance.string()
    ]
  };

  const generateRandomLedgerOutput = () => {
    return { ...body,
      resource_id: chance.guid()
    };
  };

  const getResponse = generateRandomLedgerOutput();
  const postResponse = generateRandomLedgerOutput();
  const putResponse = generateRandomLedgerOutput();

  const service = new Ledgers(mockHttp(getResponse, postResponse, putResponse) as Http, chance.url());

  describe("get", () => {
    it("should call http GET and return expected response", async () => {
      const response = await service.get(chance.guid());
      expect(response).toEqual(getResponse);
    });
  });

  describe("getall", () => {
    it("should call http GET and return expected response", async () => {
      const response = await service.getAll(chance.guid());
      expect(response).toEqual(getResponse);
    });
  });

  describe("post", () => {
    it("should call http POST and return expected response", async () => {
      const response = await service.post(body);
      expect(response).toEqual(postResponse.resource_id);
    });
  });

  describe("put", () => {
    it("should call http PUT and return expected response", async () => {
      const response = await service.put(chance.guid(), body);
      expect(response).toEqual(putResponse.resource_id);
    });
  });
});
开发者ID:trussle,项目名称:snowy-js-client,代码行数:54,代码来源:ledgers.spec.ts


注:本文中的chance.integer函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。