本文整理汇总了TypeScript中Sinon.SinonStub.getCall方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonStub.getCall方法的具体用法?TypeScript SinonStub.getCall怎么用?TypeScript SinonStub.getCall使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonStub
的用法示例。
在下文中一共展示了SinonStub.getCall方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: expect
broadcasts.forEach((broadcast, index) => {
expect(broadcastStub.getCall(index).args.length).to.be.equal(2);
expect(broadcastStub.getCall(index).args[0]).to.be.deep.equal({
name: broadcast.params.name,
});
expect(broadcastStub.getCall(index).args[1]).to.be.equal(broadcast.options);
});
示例2: inspectPushRecordCreationRequest
async function inspectPushRecordCreationRequest(t: TestContext, requestStub: SinonStub) {
// For player#create device record is already serialized. Checking serialized structure.
const anyValues = [
"device_type",
"language",
"timezone",
"device_os",
"sdk",
"delivery_platform",
"browser_name",
"browser_version",
"operating_system",
"operating_system_version",
"device_platform",
"device_model",
"identifier",
"notification_types"
];
t.is(requestStub.callCount, 1);
t.not(requestStub.getCall(0), null);
const data: any = requestStub.getCall(0).args[1];
anyValues.forEach((valueKey) => {
t.not(data[valueKey], undefined, `player create: ${valueKey} is undefined! => data: ${JSON.stringify(data)}`);
});
}
示例3: expect
.then(() => {
expect(fetch).to.have.callCount(1);
const [request] = fetch.getCall(0).args;
expect(request.headers.has('content-type')).to.equal(true);
expect(request.headers.get('content-type')).to.match(/application\/json/);
done();
}).catch(() => { done('Unexpected catch'); });
示例4: expect
.then((digestValue) => {
let call: SinonSpyCall = postStup.getCall(0);
let url: string = call.args[0];
expect(url).to.equal(digestUrl);
expect(postStup.called).is.true;
expect(digestValue).to.equal(digest);
done();
})
示例5: it
it('should successfully restore values and pass them to publisher', () => {
expect(makeStub.callCount).to.equal(0);
expect(publisherSpy.callCount).to.equal(2, 'should call once for each platform (make run)');
const darwinIndex = publisherSpy.firstCall.args[0].makeResults[0].artifacts.some((a: string) => a.indexOf('darwin') !== -1) ? 0 : 1;
const win32Index = darwinIndex === 0 ? 1 : 0;
const darwinArgs = publisherSpy.getCall(darwinIndex).args[0];
const darwinArtifacts = [];
for (const result of darwinArgs.makeResults) {
darwinArtifacts.push(...result.artifacts);
}
expect(darwinArtifacts.sort()).to.deep.equal(
fakeMake('darwin').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort(),
);
const win32Args = publisherSpy.getCall(win32Index).args[0];
const win32Artifacts = [];
for (const result of win32Args.makeResults) {
win32Artifacts.push(...result.artifacts);
}
expect(win32Artifacts.sort()).to.deep.equal(
fakeMake('win32').reduce((accum, val) => accum.concat(val.artifacts), [] as string[]).sort(),
);
});
示例6: inspectOnSessionRequest
async function inspectOnSessionRequest(t: TestContext, requestStub: SinonStub) {
// Device record is serialized inside of `updateUserSession`. Checking original DeviceRecord properties.
const anyValues = [
"deliveryPlatform",
"language",
"timezone",
"browserVersion",
"sdkVersion",
"browserName",
"subscriptionState",
"operatingSystem",
"operatingSystemVersion",
"devicePlatform",
"deviceModel",
];
t.is(requestStub.callCount, 1);
t.not(requestStub.getCall(0), null);
const data: any = requestStub.getCall(0).args[1];
anyValues.forEach((valueKey) => {
t.not(data[valueKey], undefined, `on_session: ${valueKey} is undefined! => data: ${JSON.stringify(data)}`);
});
}