当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript supertest.put函数代码示例

本文整理汇总了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();
                         }
                     });
             }
         });
 });
开发者ID:eastsideweb,项目名称:experimental,代码行数:25,代码来源:index.test.ts

示例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!!
                                             }
                                         });
                                 }
                             });
                     }
                 });
         }
     }
 });
开发者ID:eastsideweb,项目名称:experimental,代码行数:56,代码来源:index.test.ts


注:本文中的supertest.put函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。