本文整理汇总了TypeScript中supertest.put函数的典型用法代码示例。如果您正苦于以下问题:TypeScript put函数的具体用法?TypeScript put怎么用?TypeScript put使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了put函数的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('test activating/deactivating an object with the corresponding id', function (done) {
request.put('/players/' + testAccount.series.players.playerId + '/active')
.set('token', testAccount.sessionToken)
.send({ 'active': true })
.expect(200)
.end(function (err, res) {
if (err) {
done(err);
} else {
// In the spirit of keeping the test db unchanged - deactivate
request.put('/players/' + testAccount.series.players.playerId + '/active')
.set('token', testAccount.sessionToken)
.send({ 'active': false })
.expect(200)
.end(function (err, res) {
if (err) {
done(err);
}
else {
done();
}
});
}
});
});
示例2: done
.end(function (err, res) {
if (err) {
done(err);
}
else {
if (res.body.name !== testAccount.series.events.newEventObj.name) {
done({ message: "addobj failed", name: "addobj failed" });
}
else {
testAccount.series.events.newEventObjId = res.body._id;
request.put('/events/' + testAccount.series.events.newEventObjId)
.send(testAccount.series.events.newUpdateEventObj)
.set('token', testAccount.sessionToken)
.expect(200)
.end(function (err2, res2) {
if (err2) {
done(err2);
}
else {
// Find the object and confirm it was updated
request.get('/events/' + testAccount.series.events.newEventObjId)
.set('token', testAccount.sessionToken)
.expect(200)
.expect('Content-Type', /json/)
.end(function (err4, res4) {
if (err4) {
done(err4);
}
else {
// Somehow, this doesnt work - dont know how to get the name field out of this
// single json object returned.
//if (res4[0].name !== testAccount.series.events.newUpdateEventObj.name) {
// err4 = { message: "updateObj failed", name: "updateObj failed" };
//}
// we will delete the obj in any case
request.delete('/events/' + testAccount.series.events.newEventObjId)
.set('token', testAccount.sessionToken)
.expect(200)
.end(function (err3, res3) {
if (err3) {
done(err3);
}
else if (err4 !== null) {
done(err4);
}
else {
done(); // success!!
}
});
}
});
}
});
}
}
});