當前位置: 首頁>>代碼示例>>TypeScript>>正文


TypeScript supertest-as-promised.default函數代碼示例

本文整理匯總了TypeScript中supertest-as-promised.default函數的典型用法代碼示例。如果您正苦於以下問題:TypeScript default函數的具體用法?TypeScript default怎麽用?TypeScript default使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了default函數的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的TypeScript代碼示例。

示例1: it

    it('allows for custom error formatting to elaborate', async () => {
      const app = express();

      app.use(urlString(), bodyParser.json());
      app.use(urlString(), apolloExpress({
        schema: TestSchema,
        formatError(error) {
          return {
            message: error.message,
            locations: error.locations,
            stack: 'Stack trace'
          };
        }
      }));

      const response = await request(app)
        .post(urlString())
        .send({
          query: '{thrower}',
        });

      expect(response.status).to.equal(200);
      expect(JSON.parse(response.text)).to.deep.equal({
        data: null,
        errors: [ {
          message: 'Throws!',
          locations: [ { line: 1, column: 2 } ],
          stack: 'Stack trace',
        } ]
      });
    });
開發者ID:hlandao,項目名稱:apollo-server,代碼行數:31,代碼來源:testApolloServerHTTP.ts

示例2: expect

 it('applies additional validationRules', () => {
     const expected = 'AlwaysInvalidRule was really invalid!';
     const AlwaysInvalidRule = function (context) {
         return {
             enter() {
                 context.reportError(new GraphQLError(
                     expected
                 ));
                 return BREAK;
             },
         };
     };
     app = createApp({apolloOptions: {
         schema: Schema,
         validationRules: [AlwaysInvalidRule],
     }});
     const req = request(app)
         .post('/graphql')
         .send({
             query: 'query test{ testString }',
         });
     return req.then((res) => {
         expect(res.status).to.equal(400);
         return expect(res.body.errors[0].message).to.equal(expected);
     });
 });
開發者ID:HriBB,項目名稱:apollo-server,代碼行數:26,代碼來源:integrations.test.ts

示例3: request

        it('/me Route Test', async () => {

            // noinspection TypeScriptValidateTypes
            await request(app)
                .get('/api/user/me')
                .expect(401);
        });
開發者ID:Uter1007,項目名稱:sumobase.core,代碼行數:7,代碼來源:user.routes.spec.ts

示例4: Error

      it('can reject non-whitelisted queries', () => {
          const store = new OperationStore(Schema);
          store.put('query testquery{ testString }');
          const app = createApp({ apolloOptions: {
              schema: Schema,
              formatParams(params) {
                  if (params.query) {
                      throw new Error('Must not provide query, only operationName');
                  }
                  params['query'] = store.get(params.operationName);
                  return params;
              },
          }});
          const expected = [{
              data: {
                  testString: 'it works',
              },
          }, {
              errors: [{
                  message: 'Must not provide query, only operationName',
              }],
          }];

          const req = request(app)
              .post('/graphql')
              .send([{
                  operationName: 'testquery',
              }, {
                  query: '{ testString }',
              }]);
          return req.then((res) => {
              expect(res.status).to.equal(200);
              return expect(res.body).to.deep.equal(expected);
          });
      });
開發者ID:nevir,項目名稱:apollo-server,代碼行數:35,代碼來源:integrations.test.ts

示例5: test

  it('can handle batch requests', () => {
     const app = createApp();
     const expected = [
         {
             data: {
                 testString: 'it works',
             },
         },
         {
             data: {
                 testArgument: 'hello yellow',
             },
         },
     ];
     const req = request(app)
         .post('/graphql')
         .send([{
             query: `
                 query test($echo: String){ testArgument(echo: $echo) }
                 query test2{ testString }`,
             variables: { echo: 'world' },
             operationName: 'test2',
         },
         {
             query: `
                 query testX($echo: String){ testArgument(echo: $echo) }`,
             variables: { echo: 'yellow' },
             operationName: 'testX',
         }]);
     return req.then((res) => {
         expect(res.status).to.equal(200);
         return expect(res.body).to.deep.equal(expected);
     });
 });
開發者ID:nevir,項目名稱:apollo-server,代碼行數:34,代碼來源:integrations.test.ts


注:本文中的supertest-as-promised.default函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。