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


TypeScript supertest.agent函数代码示例

本文整理汇总了TypeScript中supertest.agent函数的典型用法代码示例。如果您正苦于以下问题:TypeScript agent函数的具体用法?TypeScript agent怎么用?TypeScript agent使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了agent函数的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: beforeEach

    beforeEach(() => {
      buildVerifier = new BuildVerifier(
        defaultConfig.secret,
        defaultConfig.githubToken,
        defaultConfig.repoSlug,
        defaultConfig.githubOrganization,
        defaultConfig.githubTeamSlugs,
      );
      buildCreator = new BuildCreator(defaultConfig.buildsDir);
      agent = supertest.agent((usf as any).createMiddleware(buildVerifier, buildCreator));

      spyOn(console, 'error');
    });
开发者ID:cexbrayat,项目名称:angular,代码行数:13,代码来源:upload-server-factory.spec.ts

示例2: it

    it('works', function (done) {

        const auth = kua.create(
            // Find the user based on partial user, ...credentials
            kua.basicAuth(testing.store.find),
            // ACL 
            kua.acl(ctx => ctx.user, user => user.roles));

        let app = new Koa().use(
            auth.lock(
                endPoint, ['admin', 'user'])
        );

        let request = Request.agent(listen(app));

        request.get('/')
            .set(auth.provider.key, auth.provider.encode(users.admin))
            .expect("hello")
            .end((error, r) => {
                if (error) throw (error);
            });

        request.get('/')
            .expect(407)
            .end((error, r) => {
                if (error) throw (error);
            })

        request.get('/')
            .set(auth.provider.key, auth.provider.encode(users.bob))
            .expect(200)
            .expect('hello')
            .end((error, r) => {
                if (error) throw (error);
            })

        request.get('/')
            .set(auth.provider.key, auth.provider.encode(users.guest))
            .expect(403)
            .end((error, r) => {
                if (error) throw (error);
                done();
            })

        // request.get('admin:admin@/something')            
        //     .expect(200)
        //     .end((error, r) => {
        //         if (error) throw (error);
        //         done();
        //     })
    })
开发者ID:D10221,项目名称:kua,代码行数:51,代码来源:auth_test.ts

示例3: it

    it('should test a GET method with a service that return a promise', (done) => {

        new JsRestfulRegistry(app).registerService(new TestService());

        request.agent(app).get('/books').end((err:any, res: request.Response) => {

            util.checkDefaultsJson(err, res, done);

            expect(res.body).to.eql([anyBook]);

            done();
        });

    });
开发者ID:mseemann,项目名称:js-restful-express,代码行数:14,代码来源:registry-promis.spec.ts

示例4: beforeEach

    beforeEach(() => {
      const circleCiApi = new CircleCiApi(defaultConfig.githubOrg, defaultConfig.githubRepo,
                                          defaultConfig.circleCiToken);
      const githubApi = new GithubApi(defaultConfig.githubToken);
      const prs = new GithubPullRequests(githubApi, defaultConfig.githubOrg, defaultConfig.githubRepo);
      const teams = new GithubTeams(githubApi, defaultConfig.githubOrg);

      buildRetriever = new BuildRetriever(circleCiApi, defaultConfig.downloadSizeLimit, defaultConfig.downloadsDir);
      buildVerifier = new BuildVerifier(prs, teams, defaultConfig.githubTeamSlugs, defaultConfig.trustedPrLabel);
      buildCreator = new BuildCreator(defaultConfig.buildsDir);

      const middleware = PreviewServerFactory.createMiddleware(buildRetriever, buildVerifier, buildCreator,
                                                               defaultConfig);
      agent = supertest.agent(middleware);
    });
开发者ID:BobChao87,项目名称:angular,代码行数:15,代码来源:preview-server-factory.spec.ts

示例5: it

        it('should should clear cookie', async () => {

            const agent = request.agent(app.handle);


            let res = await agent
                .get(`/test/cookie_json/?aa=bb`)

            res.should.to.have.status(200);
            res.header["set-cookie"][0].should.be.eq("cookie=j%3A%7B%22test%22%3A%22working%22%7D; Path=/; Expires=Mon, 01 Feb 2100 00:00:00 GMT");

            let res2 = await agent
                .get(`/test/cookie_clear/?aa=bb`)

            res2.header["set-cookie"][0].should.be.eq("cookie=; Path=/; Expires=Thu, 01 Jan 1970 00:00:00 GMT");
        })
开发者ID:shmoop207,项目名称:appolo,代码行数:16,代码来源:e2eSpec.ts

示例6: test

test('Throws NotFound', { skip: false }, async (t) => {
    //app: Setup ...
    let app = new Koa();
    var request = supertest.agent(listen(app));
    app.use(users.routes.get);
    const service = await getStore(true);
    
    //this: test Setup    
    request.get('/users/bob')
        .accept('application.json')        
        .expect(404)
        .end((e, r) => {
            t.assert(!e);
            t.end();
        });
});
开发者ID:D10221,项目名称:koapp,代码行数:16,代码来源:routes_test.ts

示例7: test

test('secret:401', { skip: false }, async (t) => {
    let store = await getStore(false);
    let app = new Koa()
    //Auth   
    app.use(authentication);
    //Secured
    app.use(secretRoute);    
    //...
    let request = supertest.agent(listen(app));
    request.get('/secret')
        .expect(401)
        .end(async (err, res) => {
            await delay(5);
            t.assert(!err);
            if (err) debug(`Agent: Error: ${err.message}`);
            t.end();
        });
});
开发者ID:D10221,项目名称:koapp,代码行数:18,代码来源:routes_auth_test.ts


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