本文整理匯總了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);
});
});