本文整理汇总了TypeScript中faker.date.past方法的典型用法代码示例。如果您正苦于以下问题:TypeScript date.past方法的具体用法?TypeScript date.past怎么用?TypeScript date.past使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类faker.date
的用法示例。
在下文中一共展示了date.past方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: 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)
})
示例2: getRandomPerson
export function getRandomPerson(options: GetRandomPersonOptions) {
const opts: GetRandomPersonOptions = options || {};
opts.maxDateOfBirth = opts.maxDateOfBirth || new Date(Date.now() - MS_IN_YEAR);
opts.minAge = opts.minAge || 18;
opts.maxAge = opts.maxAge || 105;
opts.depth = opts.depth || 0;
// Generates a family tree...of sorts
const result: Person = {
name: faker.name.lastName() + faker.name.firstName(),
employment: {
companyName: faker.company.companyName()
},
regex: /a/g,
age: faker.random.number(),
dateOfBirth: faker.date.past(),
enrolledToVote: faker.random.boolean(),
};
if (opts.depth > 0) {
result.parents = [
getRandomPerson({ depth: opts.depth - 1 }),
getRandomPerson({ depth: opts.depth - 1 })
];
}
return result;
}
示例3: 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
}
}
示例4: return
export const makeBook = (authorId: number): BookModel => {
return (new BookModel())
.setTitle(lorem.word())
.setDescription(lorem.sentences(2))
.setPrice(random.number(120) + (random.number(99) / 100))
.setPublishedAt(date.past())
.setAuthorId(authorId);
};
示例5: createArray
const products = createArray(numberOfProducts, i => {
return [
i,
faker.lorem.words()[0],
faker.finance.amount(),
faker.date.past(),
]
})
示例6:
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 },
};
};