本文整理匯總了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);
});
示例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");
});
示例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]);
});
示例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);
});
示例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: [] },
],
});
});
示例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);
});
示例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);
});
示例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");
});
示例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`);
});
示例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);
});