当前位置: 首页>>代码示例>>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;未经允许,请勿转载。