本文整理汇总了TypeScript中factories.createUser函数的典型用法代码示例。如果您正苦于以下问题:TypeScript createUser函数的具体用法?TypeScript createUser怎么用?TypeScript createUser使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了createUser函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: createUser
import request from 'supertest';
import { createUser } from 'factories';
import knex from '../knexClient';
import * as User from '../modules/models/user';
import * as hueLight from '../modules/models/hueLight';
import app from '../index';
import fetch from 'node-fetch';
jest.mock('node-fetch');
const user = createUser();
const hueLightRooms = [
{
lightId: 1,
roomId: '0fc1d78e-fd1c-4717-b610-65d2fa3d01b2',
},
{
lightId: 2,
roomId: '0fc1d78e-fd1c-4717-b610-65d2fa3d01b3',
},
];
describe('Hue Light API', () => {
beforeAll(async () => {
await knex(User.TABLE).insert(user);
await knex(hueLight.TABLE).insert(hueLightRooms);
});
afterAll(async () => {
await knex(User.TABLE).truncate();
await knex(hueLight.TABLE).truncate();
示例2: createUser
import knex from '../knexClient';
import * as User from '../modules/models/user';
import authenticationMiddleware from './authenticationMiddleware';
import { createUser } from 'factories';
const userTest = createUser();
describe('authenticationMiddleware', () => {
beforeAll(async () => {
await knex(User.TABLE).truncate();
});
beforeEach(async () => {
await knex(User.TABLE).insert(userTest);
});
afterEach(async () => {
await knex(User.TABLE).truncate();
});
it('should call next when user exist', async () => {
const req = {
headers: {
'x-access-token': userTest.token,
},
};
const res = { sendStatus: jest.fn(), locals: {} };
const next = jest.fn();
// @ts-ignore
await authenticationMiddleware(req, res, next);
示例3: createUser
import request from 'supertest';
import { createUser } from 'factories';
import knex from '../knexClient';
import * as Room from '../modules/models/room';
import * as User from '../modules/models/user';
import app from '../index';
const user = createUser({ userId: 'c10c80e8-49e4-4d6b-b966-4fc9fb98879f' });
const initRooms = [
{
roomId: '0fc1d78e-fd1c-4717-b610-65d2fa3d01b2',
description: 'this is a test',
name: 'room_1',
createdBy: 'c10c80e8-49e4-4d6b-b966-4fc9fb98879f',
createdAt: new Date('2018-01-01'),
updatedAt: new Date('2018-01-02'),
},
{
roomId: 'c10c80e8-49e4-4d6b-b966-4fc9fb98879f',
description: 'this is a second test',
name: 'room_2',
createdBy: 'c10c80e8-49e4-4d6b-b966-4fc9fb98879f',
createdAt: new Date('2018-01-01'),
updatedAt: new Date('2018-01-02'),
},
];
describe('Rooms API', () => {
beforeAll(async () => {
await knex(Room.TABLE).truncate();
await knex(User.TABLE).insert(user);
示例4: createUser
import request from 'supertest';
import { createUser } from 'factories';
import knex from '../knexClient';
import * as Scene from '../modules/models/scene';
import * as Action from '../modules/models/action';
import * as User from '../modules/models/user';
import app from '../index';
import dispatch from '../modules/dispatch';
jest.mock('../modules/dispatch');
const user = createUser({ userId: '29699398-449c-48fb-8f5c-84186cdf8279' });
const initScenes = [
{
sceneId: '05442486-0878-440c-9db1-a7006c25a39f',
description: 'this is a test',
name: 'scene_1',
createdBy: '29699398-449c-48fb-8f5c-84186cdf8279',
createdAt: new Date('2018-01-01'),
updatedAt: new Date('2018-01-02'),
},
{
sceneId: '18feb598-32cb-472f-8b29-a7e7fe41e06b',
description: 'this is a second test',
name: 'scene_2',
createdBy: '29699398-449c-48fb-8f5c-84186cdf8279',
createdAt: new Date('2018-01-01'),
updatedAt: new Date('2018-01-02'),
},
];