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


TypeScript assert.calledWithExactly方法代码示例

本文整理汇总了TypeScript中Sinon.assert.calledWithExactly方法的典型用法代码示例。如果您正苦于以下问题:TypeScript assert.calledWithExactly方法的具体用法?TypeScript assert.calledWithExactly怎么用?TypeScript assert.calledWithExactly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.assert的用法示例。


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

示例1: it

      it('redirects to the home page if new SAML Response is for the same user.', async () => {
        const request = requestFixture({ payload: { SAMLResponse: 'saml-response-xml' } });
        const user = { username: 'user', authentication_realm: { name: 'saml1' } };
        callWithRequest.withArgs(request, 'shield.authenticate').resolves(user);

        callWithInternalUser
          .withArgs('shield.samlAuthenticate')
          .resolves({ access_token: 'new-valid-token', refresh_token: 'new-valid-refresh-token' });

        const deleteAccessTokenStub = callWithInternalUser
          .withArgs('shield.deleteAccessToken')
          .resolves({ invalidated_tokens: 1 });

        const authenticationResult = await provider.authenticate(request, {
          accessToken: 'existing-valid-token',
          refreshToken: 'existing-valid-refresh-token',
        });

        sinon.assert.calledWithExactly(callWithInternalUser, 'shield.samlAuthenticate', {
          body: { ids: [], content: 'saml-response-xml' },
        });

        sinon.assert.calledTwice(deleteAccessTokenStub);
        sinon.assert.calledWithExactly(deleteAccessTokenStub, 'shield.deleteAccessToken', {
          body: { token: 'existing-valid-token' },
        });
        sinon.assert.calledWithExactly(deleteAccessTokenStub, 'shield.deleteAccessToken', {
          body: { refresh_token: 'existing-valid-refresh-token' },
        });

        expect(authenticationResult.redirected()).toBe(true);
        expect(authenticationResult.redirectURL).toBe('/test-base-path/');
      });
开发者ID:spalger,项目名称:kibana,代码行数:33,代码来源:saml.test.ts

示例2: it

      it('redirects to /login with optional search parameters if tokens are deleted successfully', async () => {
        const request = requestFixture({ search: '?yep' });
        const accessToken = 'foo';
        const refreshToken = 'bar';

        callWithInternalUser
          .withArgs('shield.deleteAccessToken', { body: { token: accessToken } })
          .returns({ created: true });

        callWithInternalUser
          .withArgs('shield.deleteAccessToken', { body: { refresh_token: refreshToken } })
          .returns({ created: true });

        const authenticationResult = await provider.deauthenticate(request, {
          accessToken,
          refreshToken,
        });

        sinon.assert.calledTwice(callWithInternalUser);
        sinon.assert.calledWithExactly(callWithInternalUser, 'shield.deleteAccessToken', {
          body: { token: accessToken },
        });
        sinon.assert.calledWithExactly(callWithInternalUser, 'shield.deleteAccessToken', {
          body: { refresh_token: refreshToken },
        });

        expect(authenticationResult.redirected()).toBe(true);
        expect(authenticationResult.redirectURL).toBe('/base-path/login?yep');
      });
开发者ID:spalger,项目名称:kibana,代码行数:29,代码来源:token.test.ts

示例3:

                promizr.findSeries(list, iterator).then(e => {
                    sinon.assert.calledOnce(spy);
                    sinon.assert.calledWithExactly(spy, list[0]);

                    sinon.assert.calledOnce(iterator);
                    sinon.assert.calledWithExactly(iterator, list[0], 0, list);
                }).then(done, done);
开发者ID:spatools,项目名称:promizr,代码行数:7,代码来源:collections.ts

示例4:

                .then(() => {
                    stubActionUserUpsert.restore();
                    response.redirect;

                    Sinon.assert.calledOnce(stubActionUserUpsert);
                    Sinon.assert.calledWithExactly(stubActionUserUpsert, googleUser);
                    request.session.user.should.be.equals(mongoUser);
                    request.session.access_token.should.be.equals(token);
                    Chai.assert.isUndefined(application.accessTokens[userId]);
                    Sinon.assert.calledOnce(response.redirect);
                    Sinon.assert.calledWithExactly(response.redirect, "/");
                });
开发者ID:YuriyGorvitovskiy,项目名称:Taskenize,代码行数:12,代码来源:app.ts

示例5: it

  it('should allow reusing drivers for many apps', function(done) {
    const sandbox = sinon.createSandbox();
    const spy1 = sandbox.spy();
    const spy2 = sandbox.spy();

    type NiceSources = {
      other: Stream<string>;
    };
    type NiceSinks = {
      other: Stream<string>;
    };

    function app1(sources: NiceSources): NiceSinks {
      return {
        other: sources.other.mapTo('a').debug(spy1),
      };
    }

    function app2(sources: NiceSources): NiceSinks {
      return {
        other: sources.other.mapTo('x').debug(spy2),
      };
    }

    let sinkCompleted = 0;
    function driver(sink: Stream<string>) {
      sink.addListener({
        complete: () => {
          sinkCompleted++;
          done(
            new Error('complete should not be called before engine is before')
          );
        },
      });
      return xs.of('b');
    }

    const engine = setupReusable({other: driver});

    const dispose1 = engine.run(app1(engine.sources));
    sinon.assert.calledOnce(spy1);
    sinon.assert.calledWithExactly(spy1, 'a');
    sandbox.restore();
    dispose1();

    const dispose2 = engine.run(app2(engine.sources));
    sinon.assert.calledOnce(spy2);
    sinon.assert.calledWithExactly(spy2, 'x');
    dispose2();
    assert.strictEqual(sinkCompleted, 0);
    done();
  });
开发者ID:,项目名称:,代码行数:52,代码来源:

示例6: it

        it("check main flow", () => {
            const application = new App.Application();
            const request: any = {
                logout: Sinon.stub(),
                session: {
                    access_token: "Access Token",
                    destroy: Sinon.stub().callsFake((callback: () => any) => callback()),
                },
            };
            const response = {
                redirect: Sinon.stub(),
            };
            const stubHttpsGet = Sinon.stub(Https, "get").callsFake((params, callback) => {
                params.should.be.deep.equals({
                    host: "accounts.google.com",
                    method: "GET",
                    path: "/o/oauth2/logout?token=" + request.session.access_token,
                    protocol: "https:",
                });
                callback(null);
            });

            application.passportLogout(request, response);
            stubHttpsGet.restore();

            Sinon.assert.calledOnce(request.session.destroy);
            Sinon.assert.calledOnce(request.logout);
            Sinon.assert.calledOnce(response.redirect);
            Sinon.assert.calledWithExactly(response.redirect, "/");
        });
开发者ID:YuriyGorvitovskiy,项目名称:Taskenize,代码行数:30,代码来源:app.ts


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