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