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


TypeScript assert.calledWithMatch方法代码示例

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


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

示例1: done

 sniffer.on('end', () => {
   sinon.assert.callCount(spy, 3);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match1);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match2);
   sinon.assert.calledWithMatch(spy, 'lorem-ipsum.txt.gz', match3);
   done();
 });
开发者ID:nspragg,项目名称:filesniffer,代码行数:7,代码来源:filesniffer.ts

示例2: test

  test('logs, but does not crash if the work function fails', async () => {
    let count = 0;
    const logger = mockLogger();
    const doneWorking = resolvable();
    const poller = new TaskPoller({
      store,
      logger,
      pollInterval: 1,
      work: async () => {
        ++count;
        if (count === 1) {
          throw new Error('Dang it!');
        }
        if (count > 1) {
          poller.stop();
          doneWorking.resolve();
        }
      },
    });

    poller.start();

    await doneWorking;

    expect(count).toEqual(2);
    sinon.assert.calledWithMatch(logger.error, /Dang it/i);
  });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:27,代码来源:task_poller.test.ts

示例3: test

    test('creates the task manager index', async () => {
      const callCluster = sinon.stub();
      callCluster.withArgs('indices.getTemplate').returns(Promise.resolve({ tasky: {} }));
      const store = new TaskStore({
        callCluster,
        getKibanaUuid,
        logger: mockLogger(),
        index: 'tasky',
        maxAttempts: 2,
        supportedTypes: ['a', 'b', 'c'],
      });

      await store.init();

      sinon.assert.calledTwice(callCluster); // store.init calls twice: once to check for existing template, once to put the template (if needed)

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

示例4: it

        it("check main flow", () => {
            const application = new App.Application();
            const app = Express();
            const handler: any = {handler: "authenticate"};
            const stubAppGet = Sinon.stub(app, "get");
            const stubPassportAuthenticate = Sinon.stub(Passport, "authenticate").returns(handler as Express.Handler);

            application.initPassportCallback(app);
            stubAppGet.restore();
            stubPassportAuthenticate.restore();

            Sinon.assert.calledOnce(stubPassportAuthenticate);
            stubPassportAuthenticate.args[0].length.should.be.equals(2);
            stubPassportAuthenticate.args[0][0].should.be.equals("google");
            stubPassportAuthenticate.args[0][1].should.be.deep.equals({
                failureRedirect: "/login",
                session: false,
            });

            Sinon.assert.calledOnce(stubAppGet);
            stubAppGet.calledWith("/auth/callback", handler).should.be.true;
            stubAppGet.args[0].length.should.be.equals(3);

            const callback: (req, res) => any = stubAppGet.args[0][2];
            const stubAppPassportCallback = Sinon.stub(application, "passportCallback");
            const req = {request: "Request"};
            const res = {response: "Response"};
            callback(req, res);
            Sinon.assert.calledOnce(stubAppPassportCallback);
            Sinon.assert.calledWithMatch(stubAppPassportCallback, req, res);
        });
开发者ID:YuriyGorvitovskiy,项目名称:Taskenize,代码行数:31,代码来源:app.ts

示例5: it

        it("should call executor arguments with three functions", () => {
            const
                spy = sinon.spy(),
                instance = new promizr.ProgressPromise(spy);

            sinon.assert.calledOnce(spy);
            sinon.assert.calledWithMatch(spy, sinon.match.func, sinon.match.func, sinon.match.func);
        });
开发者ID:spatools,项目名称:promizr,代码行数:8,代码来源:ProgressPromise.ts

示例6: it

		it('calls handle function with all parameters', () => {
			const handleResult = spy();
			stub(funcs, 'foo').returns('abc');

			handler.recv('[1,"abc"]', funcs, special, handleResult);

			assert.calledWithMatch(handleResult, 1, 'foo', funcs.foo, funcs, ['abc']);
		});
开发者ID:Agamnentzar,项目名称:ag-sockets,代码行数:8,代码来源:packet.spec.ts

示例7: test

    test('it returns normally with no tasks when the index does not exist.', async () => {
      const callCluster = sinon.spy(async () => ({ hits: { hits: [] } }));
      const store = new TaskStore({
        callCluster,
        supportedTypes: ['a', 'b', 'c'],
        index: 'tasky',
        maxAttempts: 2,
      });

      const result = await store.fetchAvailableTasks();

      sinon.assert.calledOnce(callCluster);
      sinon.assert.calledWithMatch(callCluster, 'search', { ignoreUnavailable: true });

      expect(result.length).toBe(0);
    });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:16,代码来源:task_store.test.ts

示例8: test

  test('warns if cancel is called on a non-cancellable task', async () => {
    const { runner, logger } = testOpts({
      definitions: {
        testType: {
          createTaskRunner: () => ({
            run: async () => undefined,
          }),
        },
      },
    });

    const promise = runner.run();
    await runner.cancel();
    await promise;

    sinon.assert.calledWithMatch(logger.warning, /not cancellable/);
  });
开发者ID:liuyepiaoxiang,项目名称:kibana,代码行数:17,代码来源:task_runner.test.ts


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