本文整理汇总了TypeScript中chance.word函数的典型用法代码示例。如果您正苦于以下问题:TypeScript word函数的具体用法?TypeScript word怎么用?TypeScript word使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了word函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
const enroll = async (kibanaURL: string, token: string) => {
const beatId = uuidv4();
await request(
{
url: `${kibanaURL}/api/beats/agent/${beatId}`,
method: 'POST',
headers: {
'kbn-xsrf': 'xxx',
'kbn-beats-enrollment-token': token,
},
body: JSON.stringify({
type: Math.random() >= 0.5 ? 'filebeat' : 'metricbeat',
host_name: `${chance.word()}.local`,
name: chance.word(),
version: '6.7.0',
}),
},
(error: any, response: any, body: any) => {
const res = JSON.parse(body);
if (res.message) {
// tslint:disable-next-line
console.log(res.message);
}
}
);
};
示例2: getRandomColor
[...Array(maxNumberOfTagsPerBeat)].map(() => {
return libs.tags.upsertTag({
name: chance.word(),
color: getRandomColor(),
hasConfigurationBlocksTypes: [] as string[],
} as BeatTag);
})
示例3: it
it('should return errors for non-existent beats and tags', async () => {
const nonExistentBeatId = chance.word();
const nonExistentTag = chance.word();
const apiResponse = await beatsLib.assignTagsToBeats(internalUser, [
{ beatId: nonExistentBeatId, tag: nonExistentTag },
]);
expect(apiResponse.assignments).toEqual([
{
result: `Beat ${nonExistentBeatId} and tag ${nonExistentTag} not found`,
status: 404,
},
]);
const beat = beatsDB.find(b => b.id === 'bar') as any;
expect(beat).not.toHaveProperty('tags');
});
示例4: 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,
});
});
示例5: beforeEach
beforeEach(async () => {
beatId = chance.word();
beat = {
host_name: 'foo.bar.com',
type: 'filebeat',
version: '6.4.0',
};
beatsDB = [];
tagsDB = [];
tokensDB = [];
getBeatsLib();
});
示例6: it
it('should reject an invalid enrollment token', async () => {
const { token } = await tokensLib.getEnrollmentToken(chance.word());
expect(token).toEqual(null);
});