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


TypeScript assert.calledOnce方法代码示例

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


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

示例1: test

    test('writes documents in bulk to the index', async () => {
      const index = '.myalias';
      const callCluster = sinon.stub();
      const docs = [
        {
          _id: 'niceguy:fredrogers',
          _source: {
            type: 'niceguy',
            niceguy: {
              aka: 'Mr Rogers',
            },
            quotes: ['The greatest gift you ever give is your honest self.'],
          },
        },
        {
          _id: 'badguy:rickygervais',
          _source: {
            type: 'badguy',
            badguy: {
              aka: 'Dominic Badguy',
            },
            migrationVersion: { badguy: '2.3.4' },
          },
        },
      ];

      callCluster.returns(
        Promise.resolve({
          items: [],
        })
      );

      await Index.write(callCluster, index, docs);

      sinon.assert.calledOnce(callCluster);
      expect(callCluster.args[0]).toMatchSnapshot();
    });
开发者ID:salihkardan,项目名称:kibana,代码行数:37,代码来源:elastic_index.test.ts

示例2: it

    it('fails if new access token is rejected after successful refresh', async () => {
      const request = requestFixture();

      callWithRequest
        .withArgs(sinon.match({ headers: { authorization: 'Bearer foo' } }), 'shield.authenticate')
        .rejects({ statusCode: 401 });

      callWithInternalUser
        .withArgs('shield.getAccessToken', {
          body: { grant_type: 'refresh_token', refresh_token: 'bar' },
        })
        .resolves({ access_token: 'newfoo', refresh_token: 'newbar' });

      const authenticationError = new errors.AuthenticationException('Some error');
      callWithRequest
        .withArgs(
          sinon.match({ headers: { authorization: 'Bearer newfoo' } }),
          'shield.authenticate'
        )
        .rejects(authenticationError);

      const accessToken = 'foo';
      const refreshToken = 'bar';
      const authenticationResult = await provider.authenticate(request, {
        accessToken,
        refreshToken,
      });

      sinon.assert.calledTwice(callWithRequest);
      sinon.assert.calledOnce(callWithInternalUser);

      expect(request.headers).not.toHaveProperty('authorization');
      expect(authenticationResult.failed()).toBe(true);
      expect(authenticationResult.user).toBeUndefined();
      expect(authenticationResult.state).toBeUndefined();
      expect(authenticationResult.error).toEqual(authenticationError);
    });
开发者ID:spalger,项目名称:kibana,代码行数:37,代码来源:token.test.ts

示例3: it

  it('should allow disposing the engine, stopping reusability', function(done) {
    const sandbox = sinon.createSandbox();
    const spy = sandbox.spy();

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

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

    let sinkCompleted = 0;
    function driver(sink: Stream<string>) {
      sink.addListener({
        complete: () => {
          sinkCompleted++;
        },
      });
      return xs.of('b');
    }

    const engine = setupReusable<NiceSources, NiceSinks>({other: driver});

    engine.run(app(engine.sources));
    sinon.assert.calledOnce(spy);
    sinon.assert.calledWithExactly(spy, 'a');
    sandbox.restore();
    engine.dispose();
    assert.strictEqual(sinkCompleted, 1);
    done();
  });
开发者ID:ntilwalli,项目名称:cyclejs,代码行数:37,代码来源:setupReusable.ts

示例4: test

    test('fails if any document fails', async () => {
      const index = '.myalias';
      const callCluster = sinon.stub();
      const docs = [
        {
          _id: 'niceguy:fredrogers',
          _source: {
            type: 'niceguy',
            niceguy: {
              aka: 'Mr Rogers',
            },
          },
        },
      ];

      callCluster.returns(
        Promise.resolve({
          items: [{ index: { error: { type: 'shazm', reason: 'dern' } } }],
        })
      );

      await expect(Index.write(callCluster, index, docs)).rejects.toThrow(/dern/);
      sinon.assert.calledOnce(callCluster);
    });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:24,代码来源:elastic_index.test.ts

示例5: test

    test('creates the task manager index', async () => {
      const callCluster = sinon.spy();
      const store = new TaskStore({
        callCluster,
        index: 'tasky',
        maxAttempts: 2,
        supportedTypes: ['a', 'b', 'c'],
      });

      await store.init();

      sinon.assert.calledOnce(callCluster);

      sinon.assert.calledWithMatch(callCluster, 'indices.putTemplate', {
        body: {
          index_patterns: ['tasky'],
          settings: {
            number_of_shards: 1,
            auto_expand_replicas: '0-1',
          },
        },
        name: 'tasky',
      });
    });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:24,代码来源:task_store.test.ts

示例6: it

    it('clears session if it belongs to not configured provider.', async () => {
      // Add `kbn-xsrf` header to the raw part of the request to make `can_redirect_request`
      // think that it's AJAX request and redirect logic shouldn't be triggered.
      const systemAPIRequest = requestFixture({
        headers: { xCustomHeader: 'xxx', 'kbn-xsrf': 'xsrf' },
      });
      const notSystemAPIRequest = requestFixture({
        headers: { xCustomHeader: 'yyy', 'kbn-xsrf': 'xsrf' },
      });

      session.get.withArgs(systemAPIRequest).resolves({
        state: { accessToken: 'some old token' },
        provider: 'token',
      });

      session.get.withArgs(notSystemAPIRequest).resolves({
        state: { accessToken: 'some old token' },
        provider: 'token',
      });

      session.clear.resolves();

      server.plugins.kibana.systemApi.isSystemApiRequest
        .withArgs(systemAPIRequest)
        .returns(true)
        .withArgs(notSystemAPIRequest)
        .returns(false);

      const systemAPIAuthenticationResult = await authenticate(systemAPIRequest);
      expect(systemAPIAuthenticationResult.notHandled()).toBe(true);
      sinon.assert.calledOnce(session.clear);

      const notSystemAPIAuthenticationResult = await authenticate(notSystemAPIRequest);
      expect(notSystemAPIAuthenticationResult.notHandled()).toBe(true);
      sinon.assert.calledTwice(session.clear);
    });
开发者ID:,项目名称:,代码行数:36,代码来源:

示例7: it

			it('calls connected when client connects', () => {
				assert.calledOnce(connected);
			});
开发者ID:Agamnentzar,项目名称:ag-sockets,代码行数:3,代码来源:serverClient.spec.ts

示例8: setTimeout

 setTimeout(() => {
   sinon.assert.calledOnce(disposeSpy)
   sandbox.restore()
   done()
 })
开发者ID:TylorS,项目名称:tempest,代码行数:5,代码来源:index.ts

示例9: setTimeout

            setTimeout(() => {
                sinon.assert.calledOnce(callback);
                sinon.assert.calledOnce(callback2);

                done();
            }, 1);
开发者ID:spatools,项目名称:promizr,代码行数:6,代码来源:tasks.ts


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