本文整理汇总了TypeScript中chai.request类的典型用法代码示例。如果您正苦于以下问题:TypeScript request类的具体用法?TypeScript request怎么用?TypeScript request使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了request类的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: describe
describe('Test Case: Changing Passwords: ', () => {
let JWT: string;
let agent = chai.request.agent(server);
for (let i = 0; i < TEST_CHANGE_PASSWORDS_COUNT; ++i) {
it('Login and change passwords: ' + i, function (done: any) {
agent
.post('/api/members/login')
.send({
firstname: 'test' + test_member_index,
emailaddress: 'test' + test_member_index + '@example.com',
password: passwords[i]
})
.then(function (res: any) {
res.should.have.status(200);
res.should.be.json;
JWT = res.body.jwt;
})
.then(() => agent.post('/api/members/' + JWT + '/change-password').set('x-auth', JWT).send({ password: passwords[i + 1] }))
.then((res: any) => {
res.should.have.status(200);
done();
})
.catch(done);
});
}
});
示例2: it
it('Failed Login', function (done: any) {
let agent = chai.request.agent(server);
agent
.post('/api/members/login')
.send({ firstname: 'nonsense', emailaddress: 'nonsense@example.com', password: 'nonsense' })
.then((res: any) => done('Test failure: Signup did not fail'))
.catch((res: any) => {
res.should.have.status(401);
done();
})
.catch(done);
});