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


TypeScript assert.calledWith方法代码示例

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


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

示例1: it

    it('predicates are called with the same context and proper arguments', function () {
        const exampleContext = {some: 'context'},
            structure = {
                key0: sinon.stub().returns(true),
                key1: sinon.stub().returns(true)
            },
            exampleObject = {
                key0: 1,
                key1: 'string'
            };

        const extraArgs = [2, 3];
        const args = [exampleObject, ...extraArgs];
        isValidStructure.call(exampleContext, structure, ...args);
        isValidStructure(structure).call(exampleContext, ...args);

        sinon.assert.calledTwice(structure.key0);
        sinon.assert.calledTwice(structure.key1);

        sinon.assert.alwaysCalledOn(structure.key0, exampleContext);
        sinon.assert.alwaysCalledOn(structure.key1, exampleContext);

        sinon.assert.calledWith(structure.key0, 1, ...extraArgs);
        sinon.assert.calledWith(structure.key1, 'string', ...extraArgs);
    });
开发者ID:wookieb,项目名称:predicates,代码行数:25,代码来源:structureTest.ts

示例2: test

test("test for namespace parsing.", (t) => {
  const element = obtainElementTag(gomlParserTestCasePath4);
  const node = GomlParser.parse(element);
  node.setMounted(true);
  node.broadcastMessage("onTest", "testArg");
  sinon.assert.calledWith(conflictComponent1Spy, "aaa");
  sinon.assert.calledWith(conflictComponent2Spy, "bbb");
});
开发者ID:emadurandal,项目名称:GrimoireJS,代码行数:8,代码来源:GomlParserTest.ts

示例3: it

            it("using each reactions and expectedResolution as second argument", () => {
                var reactions = reactionsHelpers.createFakeReactions(3),
                    expectedResolution = { value: "Yoopie !" };

                abstract.triggerPromiseReaction(reactions, expectedResolution);

                sinon.assert.calledWith(enqueueTaskStub, abstract.PromiseReactionTask, [reactions[0], expectedResolution]);
                sinon.assert.calledWith(enqueueTaskStub, abstract.PromiseReactionTask, [reactions[1], expectedResolution]);
                sinon.assert.calledWith(enqueueTaskStub, abstract.PromiseReactionTask, [reactions[2], expectedResolution]);
            });
开发者ID:spatools,项目名称:promizr,代码行数:10,代码来源:abstract.ts

示例4: it

    it("sends one status ping when status is changed", async function() {
      const sendPingStub = sinon.stub(store, "sendOptInStatusPing").resolves(true);
      await store.setOptOut(true);
      sinon.assert.calledWith(sendPingStub, false);

      sendPingStub.reset();
      await store.setOptOut(true);
      sinon.assert.notCalled(sendPingStub);

      await store.setOptOut(false);
      sinon.assert.calledWith(sendPingStub, true);
    });
开发者ID:drvegass,项目名称:telemetry,代码行数:12,代码来源:index.spec.ts

示例5: test

  test('transforms all docs from the original index', async () => {
    let count = 0;
    const opts = defaultOpts();
    const callCluster = clusterStub(opts);
    const migrateDoc = sinon.spy((doc: RawSavedObjectDoc) => ({
      ...doc,
      attributes: { name: ++count },
    }));

    opts.documentMigrator = {
      migrationVersion: { foo: '1.2.3' },
      migrate: migrateDoc,
    };

    withIndex(callCluster, {
      numOutOfDate: 1,
      docs: [
        [{ _id: 'foo:1', _source: { type: 'foo', foo: { name: 'Bar' } } }],
        [{ _id: 'foo:2', _source: { type: 'foo', foo: { name: 'Baz' } } }],
      ],
    });

    await new IndexMigrator(opts).migrate();

    expect(count).toEqual(2);
    sinon.assert.calledWith(migrateDoc, {
      id: '1',
      type: 'foo',
      attributes: { name: 'Bar' },
      migrationVersion: {},
      references: [],
    });
    sinon.assert.calledWith(migrateDoc, {
      id: '2',
      type: 'foo',
      attributes: { name: 'Baz' },
      migrationVersion: {},
      references: [],
    });
    expect(callCluster.args.filter(([action]) => action === 'bulk').length).toEqual(2);
    sinon.assert.calledWith(callCluster, 'bulk', {
      body: [
        { index: { _id: 'foo:1', _index: '.kibana_2' } },
        { foo: { name: 1 }, type: 'foo', migrationVersion: {}, references: [] },
      ],
    });
    sinon.assert.calledWith(callCluster, 'bulk', {
      body: [
        { index: { _id: 'foo:2', _index: '.kibana_2' } },
        { foo: { name: 2 }, type: 'foo', migrationVersion: {}, references: [] },
      ],
    });
  });
开发者ID:lucabelluccini,项目名称:kibana,代码行数:53,代码来源:index_migrator.test.ts

示例6: MockScopedHttpClient

test.cb('appveyor > build', (t) => {
  const token = 'my-token';
  const account = 'my-account';
  const project = 'my-project';
  const response = {
    "buildId": 136709,
    "jobs": [],
    "buildNumber": 7,
    "version": "1.0.7",
    "message": "replaced with command [skip ci]",
    "branch": "master",
    "commitId": "c2892a70d60c96c1b65a7c665ab806b7731fea8a",
    "authorName": "Feodor Fitsner",
    "authorUsername": "FeodorFitsner",
    "committerName": "Feodor Fitsner",
    "committerUsername": "FeodorFitsner",
    "committed": "2014-08-15T22:05:54+00:00",
    "messages": [],
    "status": "queued",
    "created": "2014-08-16T00:40:38.1703914+00:00"
  };

  const httpClient = new MockScopedHttpClient();

  const headerSpy = sinon.spy(httpClient, 'header');

  const postStub = sinon.stub(httpClient, 'post');
  postStub.returns((handler: IHttpClientHandler) => {
    handler(null, { statusCode: 200 }, JSON.stringify(response));
  });

  const httpStub = sinon.stub().returns(httpClient);

  const appveyor = new AppVeyor(httpStub, token, account);
  const result = appveyor.build(project);

  sinon.assert.calledWith(httpStub, 'https://ci.appveyor.com/api/builds');
  sinon.assert.calledWith(headerSpy, 'Authorization', `Bearer ${token}`);
  sinon.assert.calledWith(headerSpy, 'Content-Type', 'application/json');
  sinon.assert.calledWith(headerSpy, 'Accept', 'application/json');
  sinon.assert.calledWith(postStub, `{"accountName":"${account}","projectSlug":"${project}"}`);

  result.then((data) => {
    t.is(data.ok, true);
    t.is(data.statusCode, 200);
    t.is(data.body.accountName, account);
    t.is(data.body.projectSlug, project);
    t.is(data.body.version, response.version);
    t.is(data.body.link, `https://ci.appveyor.com/project/${account}/${project}/build/${response.version}`);

    t.end();
  }).catch(t.end);
});
开发者ID:adamwitko,项目名称:hubot-appveyor,代码行数:53,代码来源:appveyor.test.ts

示例7: it

    it('calls a predicate with the same context and proper arguments', function () {
        const exampleContext = {some: 'property'};
        const stub = sinon.stub().returns(true);

        const arr = [1, 2];
        const extraArgs = ['super', 'extra', 'args'];
        isArrayOf(stub).call(exampleContext, arr, ...extraArgs);
        isArrayOf.call(exampleContext, stub, arr, ...extraArgs);

        sinon.assert.callCount(stub, 4);
        sinon.assert.alwaysCalledOn(stub, exampleContext);
        sinon.assert.calledWith(stub, 1, ...extraArgs);
        sinon.assert.calledWith(stub, 2, ...extraArgs);
    });
开发者ID:wookieb,项目名称:predicates,代码行数:14,代码来源:arrayOfTest.ts

示例8: it

        it("should awake created pureComputed when given pureComputed awake", () => {
            const spy = sinon.spy();
            pure = purifier.purify(base, () => spy(obs()));

            obs("value_2");
            sinon.assert.notCalled(spy);

            subs.push(base.subscribe(() => true));
            sinon.assert.calledOnce(spy);
            sinon.assert.calledWith(spy, "value_2");

            obs("value_3");
            sinon.assert.calledTwice(spy);
            sinon.assert.calledWith(spy, "value_3");
        });
开发者ID:spatools,项目名称:koutils,代码行数:15,代码来源:purifier.ts

示例9: test

test('finbot > starts a deploy > handles non-200 response', (t) => {
  // arrange
  const robot = new MockRobot();
  const respondStub = sinon.stub(robot, 'respond');

  const response = new MockResponse();
  const replyStub = sinon.stub(response, 'reply');

  respondStub.callsArgWith(1, response);

  response.match = [null, 'project', 'version', 'environment'];
  response.message = {
    room: 'asdasdasd',
    user: { name: 'a name' }
  };

  const deployResponse = {
    ok: false,
    statusCode: 403
  };
  const deployPromise = Promise.resolve(deployResponse);
  sinon.stub(deployPromise, 'then')
    .callsArgWith(0, deployResponse)
    .returns(Promise.resolve());

  const appVeyor = new MockAppVeyor();
  sinon.stub(appVeyor, 'deploy').returns(deployPromise);

  // act
  DeployScript(robot, appVeyor);

  // assert
  sinon.assert.calledWith(replyStub, `Could not deploy. Got status code 403`);
});
开发者ID:adamwitko,项目名称:hubot-appveyor,代码行数:34,代码来源:deploy.test.ts

示例10: it

		it('should read VERSION message from websocket', () => {
			const version = stub(special, '*version');

			handler.recv(JSON.stringify([MessageType.Version, 123]), funcs, special);

			assert.calledWith(version, 123);
		});
开发者ID:Agamnentzar,项目名称:ag-sockets,代码行数:7,代码来源:debugPacket.spec.ts


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