本文整理汇总了TypeScript中supertest.default函数的典型用法代码示例。如果您正苦于以下问题:TypeScript default函数的具体用法?TypeScript default怎么用?TypeScript default使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了default函数的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should retun 400 if request is invalid', async () => {
const response = await request(app)
.post('/api/dios')
.set('Accept', 'application/json')
.set('x-access-token', user.token)
.send({
dioId: 1,
name: 'test_post',
roomId: '0fc1d78e-fd1c-4717-b610-65d2fa3d01b2',
admin: true,
});
expect(response.status).toBeBadRequest();
});
示例2: it
it('should retun 200 when user is authenticated', async () => {
const response = await request(app)
.get('/api/users')
.set('Accept', 'application/json')
.set('x-access-token', user.token)
.send();
expect(response.body).toEqual([
{
username: user.username,
userId: user.userId,
},
]);
});
示例3: it
it('should run the routine', async () => {
const runSpy = jest.spyOn(Routine, 'run');
const response = await request(app)
.get(`/api/routines/${initRoutines[0].routineId}/action`)
.set('Accept', 'application/json')
.set('x-access-token', user.token);
expect(response.status).toHaveStatusOk();
expect(response.body).toEqual({});
expect(Routine.run).toHaveBeenCalled();
expect(runSpy.mock.calls).toMatchSnapshot();
runSpy.mockRestore();
});
示例4: expect
it('can handle a basic implicit GET request', () => {
app = createApp();
const expected = {
testString: 'it works',
};
const query = {
query: '{ testString }',
};
const req = request(app)
.get('/graphql').query(query);
return req.then((res) => {
expect(res.status).to.equal(200);
return expect(res.body.data).to.deep.equal(expected);
});
});