本文整理汇总了TypeScript中faker.lorem.words方法的典型用法代码示例。如果您正苦于以下问题:TypeScript lorem.words方法的具体用法?TypeScript lorem.words怎么用?TypeScript lorem.words使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.lorem
的用法示例。
在下文中一共展示了lorem.words方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: async
doTest = async (modelClazz,repoClazz) => {
try {
let
model = new modelClazz(),
repo = coordinator.getRepo(repoClazz)
Object.assign(model, {
id: uuid.v4(),
createdAt: Faker.date.past(),
randomText: Faker.lorem.words(10)
})
model = await repo.save(model)
const
model2 = Object.assign(new modelClazz(),model, {
randomText: Faker.lorem.words(10),
$$doc: Object.assign({},(model as any).$$doc,{
_rev: '1-aa86c0e405a07fb76ef3e523dd1c2ae1'
}),
})
await repo.save(model2)
return null
} catch (anErr) {
return anErr
}
}
示例2: it
it('#finder-fn',async () => {
const repo = coordinator.getRepo(Fixtures.IDBRepo1)
const models = []
const name = 'hello',
name2 = `${name} ${name}`
for (let x = 0; x < 10;x++) {
const model = new Fixtures.IDBModel1()
Object.assign(model,{
id: uuid.v4(),
name,
createdAt: Faker.date.past(),
randomText: Faker.lorem.words(10)
})
models.push(model)
}
await repo.bulkSave(...models)
let results = await repo.findByName(name)
expect(results.length).toBe(models.length)
// Testing second batch to make sure not all
const models2 = []
for (let x = 0; x < 20;x++) {
const model = new Fixtures.IDBModel1()
Object.assign(model,{
id: uuid.v4(),
name: name2,
createdAt: Faker.date.past(),
randomText: Faker.lorem.words(10)
})
models2.push(model)
}
await repo.bulkSave(...models2)
const results2 = await repo.findByName(name2)
expect(results2.length).toBe(models2.length)
// Test name 1 again to confirm
results = await repo.findByName(name)
expect(results.length).toBe(models.length)
const keys = models.concat(models2).map(result => repo.key(result.id))
await repo.bulkRemove(...keys)
expect(await repo.count()).toBe(0)
})
示例3: fakeModel
function fakeModel() {
const model = new Fixtures.PDBModel1()
Object.assign(model, {
id: uuid.v4(),
name: Faker.lorem.words(1),
createdAt: Faker.date.past(),
randomText: Faker.lorem.words(10)
})
return model
}
示例4: it
it('#bulkSave+bulkRemove', async() => {
const repo = coordinator.getRepo(Fixtures.PDBRepo1)
const models = []
for (let i = 0; i < 1000; i++) {
const model = new Fixtures.PDBModel1()
Object.assign(model, {
id: uuid.v4(),
createdAt: Faker.date.past(),
randomText: Faker.lorem.words(10)
})
models.push(model)
}
const savedModels = await repo.bulkSave(...models)
expect(savedModels.length).toBe(models.length)
//const nextCount = await repo.count()
//expect(nextCount).toBe(models.length)
const ids = savedModels.map(savedModel => savedModel.id)
models.forEach(model => expect(model.$$doc).not.toBeNull())
await repo.bulkRemove(...ids)
const finalCount = await repo.count()
expect(finalCount).toBe(0)
})
示例5: createArray
const products = createArray(numberOfProducts, i => {
return [
i,
faker.lorem.words()[0],
faker.finance.amount(),
faker.date.past(),
]
})
示例6: 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(),
};
}