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


TypeScript faker.date类代码示例

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


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

示例1: it

  it('each PanelListItem should contain a link to its details', () => {
    const panels: PanelListItem[] = [
      {
        id: faker.random.uuid(),
        title: faker.random.words(),
        startDate: faker.date.recent(),
        endDate: faker.date.future()
      }
    ];

    const action = new PanelActions.LoadPanelsSuccess(panels);

    store.dispatch(action);

    component.panels$.subscribe(data => {
      expect(data.length).toBe(panels.length);
    });

    fixture.whenStable().then(() => {
      let href = fixture.debugElement
        .query(By.css('.panel-details'))
        .nativeElement.getAttribute('href');
      expect(href).toEqual('/create-panel');
    });
  });
开发者ID:ArmyMusicOnline,项目名称:ami,代码行数:25,代码来源:panel-list.component.spec.ts

示例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)

	})
开发者ID:densebrain,项目名称:typestore,代码行数:56,代码来源:IndexedDBPlugin.spec.ts

示例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
						
					}
				}
开发者ID:densebrain,项目名称:typestore,代码行数:30,代码来源:PouchDBPlugin.spec.ts

示例4: it

			it('#puts', async() => {
				const
					model = new Fixtures.PDBModel1(),
					repo = coordinator.getRepo(Fixtures.PDBRepo1)
				
				Object.assign(model, {
					id: uuid.v4(),
					createdAt: Faker.date.past(),
					randomText: Faker.lorem.words(10)
				})
				
				const
					savedModel = await repo.save(model),
					key = repo.key(model.id)
				
				// Check we got a doc value
				expect((savedModel as any).$$doc).not.toBe(null)
				
				let
					modelGet = await repo.get(key)
				
				expect(modelGet.id).toBe(model.id)
				expect(modelGet.randomText).toBe(model.randomText)
				
				let currentCount = await repo.count()
				expect(currentCount).toBe(1)
				
				await repo.remove(key)
				expect(await repo.count()).toBe(0)
				
			})
开发者ID:densebrain,项目名称:typestore,代码行数:31,代码来源:PouchDBPlugin.spec.ts

示例5: 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;
}
开发者ID:codeandcats,项目名称:fast-clone,代码行数:29,代码来源:dataHelper.ts

示例6: createArray

 const products = createArray(numberOfProducts, i => {
     return [
         i,
         faker.lorem.words()[0],
         faker.finance.amount(),
         faker.date.past(),
     ]
 })
开发者ID:jakobrun,项目名称:gandalf,代码行数:8,代码来源:generatePgData.ts

示例7: 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);
};
开发者ID:w3tecch,项目名称:node-ts-boilerplate,代码行数:8,代码来源:BookFactory.ts


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