當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。