本文整理汇总了TypeScript中supertest-as-promised.agent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript agent函数的具体用法?TypeScript agent怎么用?TypeScript agent使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了agent函数的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('/Check Test; e-mail address of non-existing user', async () => {
let agent = request.agent(app);
await agent
.head('/api/user/check')
.set('email', 'somebody.else@somewhere.else')
.expect(200); // 200 = "doesn't exist"
});
示例2: before
before(function() {
if ((process as any).browser) {
// Bitgo Express tests not supported in browser
this.skip();
}
const args = {
debug: false,
env: 'test',
logfile: '/dev/null'
};
const app = expressApp(args);
agent = request.agent(app);
});
示例3: it
it('error - proxied calls disabled', function() {
const app = expressApp(_.extend(
{},
{
debug: false,
env: 'test',
logfile: '/dev/null'
},
{ disableproxy: true })
);
const disabledProxyAgent = request.agent(app);
return disabledProxyAgent.get('/api/v1/market/latest')
.send()
.then(function(res) {
res.should.have.status(404);
});
});
示例4: describe
describe('Restricted Routes LoggedIn', () => {
let agent = request.agent(app);
beforeEach(async () => {
// noinspection TypeScriptValidateTypes
await agent
.post('/api/user/login')
.type('form')
.send({'email': 'christoph.ott@lean-coders.at', 'password': '123appTest$!'});
});
describe('/me Route Test', () => {
it('/Login Test; logged-in + able to call a protected route', async () => {
// noinspection TypeScriptValidateTypes
await agent
.get('/api/user/me')
.expect(200);
});
});
});
示例5: request
request(app)
.get("/kittens")
.expect(200)
.then(res => {
// ...
});
describe("GET /kittens", () => {
it("should work", () => {
return request(app).get("/kittens").expect(200);
});
});
// Agents
var agent = request.agent(app);
agent
.get("/ugly-kitteh")
.expect(404)
.then(() => {
// ...
});
// Promisey goodness
request(app)
.get("/kittens")
.expect(201)
.then(res => { /* ... */ })
// I'm a real promise now!
.catch(err => { /* ... */ });
示例6: request
.then(res => {
// ...
});
// Usage
request(app)
.get("/kittens")
.expect(200)
.then(res => {
// ...
});
request(app).get("/kittens").expect(200);
// Agents
const agent = request.agent(app);
agent
.get("/ugly-kitteh")
.expect(404)
.then(() => {
// ...
});
// Promisey goodness
request(app)
.get("/kittens")
.expect(201)
.then(res => { /* ... */ })
// I'm a real promise now!
.catch(err => { /* ... */ });