本文整理汇总了TypeScript中faker.lorem.sentence方法的典型用法代码示例。如果您正苦于以下问题:TypeScript lorem.sentence方法的具体用法?TypeScript lorem.sentence怎么用?TypeScript lorem.sentence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.lorem
的用法示例。
在下文中一共展示了lorem.sentence方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: makeNodes
function makeNodes(n: number = defaultN) {
const values: any[] = []
for (let i = 0; i < n; i++) {
values.push({
_typeName: 'Post',
id: String(start + i),
title: faker.lorem.sentence(),
description: faker.lorem.paragraphs(),
state: 'Published',
})
}
for (let i = 0; i < n; i++) {
values.push({
_typeName: 'Comment',
id: String(start + n + i),
text: faker.lorem.sentence(),
})
}
return {
valueType: 'nodes',
values,
}
}
示例2:
const createMessage = (channelId) => {
return {
id: faker.random.uuid(),
content: faker.lorem.sentence(),
creationTime: faker.date.past().getTime().toString(),
author: {
name: faker.name.firstName() + '.' + faker.name.lastName(),
avatar: faker.image.avatar(),
},
channel: { id: channelId },
};
};
示例3: getFakerData
/**
* Use faker to generate metadata for the inputs
* @param {type}
* the type of input to generate metadata for
*/
getFakerData(type): any {
switch (type) {
case 'string':
return faker.lorem.sentence();
case 'boolean':
return Math.random() > 0.5;
case 'sentence':
return faker.lorem.sentence();
case 'image':
let width = Math.floor(Math.random() * (500 - 300 + 1) + 300);
let height = Math.floor(Math.random() * (300 - 250 + 1) + 300);
return faker.image.imageUrl(width, height);
case 'avatar':
return faker.image.avatar();
case 'words':
return faker.lorem.words();
case 'phone':
return faker.phone.phoneNumber();
case 'name':
return faker.name.findName();
default:
return null;
}
}
示例4: createFakeRowObjectData
createFakeRowObjectData(index: number): Object {
return {
id: index,
avartar: faker.image.avatar(),
city: faker.address.city(),
email: faker.internet.email(),
firstName: faker.name.firstName(),
lastName: faker.name.lastName(),
street: faker.address.streetName(),
zipCode: faker.address.zipCode(),
date: faker.date.past(),
bs: faker.company.bs(),
catchPhrase: faker.company.catchPhrase(),
companyName: faker.company.companyName(),
words: faker.lorem.words(),
sentence: faker.lorem.sentence(),
};
}
示例5: initDb
/** Create the database. */
async function initDb() {
// Creates the file.
try {
await sequelize.authenticate();
console.log('Connection to the database successful.');
} catch (error) {
console.log(`Error while trying to connect to the database: ${error}`);
}
// Syncs the model
try {
await sequelize.sync({force: true});
console.log('Database sync sucessful');
} catch (error) {
console.log(`Error while trying to sync the model with the database : ${error}`);
}
if (process.env.DB_ENV !== 'prod') {
// Populate the database with fake data
try {
let data: IArticle[] = [];
for (let i = 0; i < 10; i++) {
data.push({
title: faker.commerce.department(),
description: faker.lorem.sentence(),
content: faker.lorem.sentences(),
published: faker.random.boolean(),
publishedAt: new Date().toISOString()
});
}
await Article.bulkCreate(data);
console.log('10 articles successfully inserted.');
} catch (error) {
console.log(`Error while trying to insert an article in the database : ${error}`);
}
}
}
示例6: beforeEach
beforeEach((done: Function) => {
error = new Error(faker.lorem.sentence());
daoStub.returns(Promise.reject(error));
AuthController.register(request, response, next)
.then(() => done());
});
示例7: insertCard
cards.splice(index, 1);
});
}
export function insertCard(board: KanbanBoard, card: Card, listId: number, index: number) {
return updateCards(board, listId, cards => {
cards.splice(index, 0, card);
});
}
export const initialBoard: KanbanBoard = [
{
id: 0,
title: "To Do",
cards: [
{ id: 1, title: faker.lorem.sentence() },
{ id: 2, title: faker.lorem.sentence() },
{ id: 3, title: faker.lorem.sentence() },
{ id: 4, title: faker.lorem.sentence() },
{ id: 5, title: "This card is a bigger than the other ones. "
+ faker.lorem.sentence() + " " + faker.lorem.sentence() }
]
},
{
id: 1,
title: "Doing",
cards: [
{ id: 6, title: faker.company.bs() },
{ id: 7, title: faker.company.bs() },
{ id: 8, title: faker.company.bs() },
{ id: 9, title: faker.company.bs() },
示例8: addFakeUsers
async addFakeUsers(count: number = 20) {
let i = count;
while (i--) {
try {
let password = faker.internet.password();
const { user, channel } = await userController.create({ id: null }, {
_id: undefined,
name: faker.name.findName(),
email: faker.internet.email(),
country: faker.address.countryCode(),
password: password,
profileImg: faker.image.avatar(),
description: faker.lorem.sentence()
});
console.log(i, 'user-id:', user._id, ' channel-id:', channel._id);
} catch (error) {
console.error('USER ERROR', error);
}
}
process.exit();
},
async checkUser(id: string) {
const user = await userController.findById({ id }, id);
const channel = await channelController.findById({ id }, id);