本文整理汇总了TypeScript中Sinon.SinonSpy类的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonSpy类的具体用法?TypeScript SinonSpy怎么用?TypeScript SinonSpy使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SinonSpy类的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的TypeScript代码示例。
示例1: it
it("Sets the game name if it is allowed", () => {
const spy: SinonSpy = sinon.spy();
element.element.value = allowedName;
subscribe(channel, spy);
expect(nameInput(element)).to.equal(allowedName);
expect(spy.calledWith(allowedName)).to.equal(true);
});
开发者ID:Ruddickmg,项目名称:js-wars,代码行数:7,代码来源:gameNameEntry.spec.ts
示例2: describe
describe('applyHeaders', () => {
let normalizeSpy: SinonSpy;
let updateSpy: SinonSpy;
beforeEach(() => {
normalizeSpy = sinon.spy(instance, 'normalize');
updateSpy = sinon.spy(instance, 'update');
});
afterEach(() => {
normalizeSpy.restore();
updateSpy.restore();
});
it('should call normalize and update', () => {
const retVal = instance.applyHeaders(undefined);
expect(retVal).to.deep.equal({ port: 0, state: 1 });
expect(normalizeSpy.called).to.be.true;
expect(updateSpy.calledOnce).to.be.true;
});
it('should return headers', () => {
const header = { something: 'header' };
const retVal = instance.applyHeaders(header as any);
expect(retVal).to.deep.equal({ port: 0, state: 1, something: 'header' });
expect(normalizeSpy.called).to.be.true;
expect(updateSpy.calledOnce).to.be.true;
});
});
开发者ID:RiseVision,项目名称:rise-node,代码行数:29,代码来源:peer.spec.ts
示例3: cleanSpy
export function cleanSpy(spy: SinonSpy) {
if (spy) {
if (spy.restore) {
spy.restore();
}
spy.reset();
}
}
开发者ID:spatools,项目名称:promizr,代码行数:9,代码来源:common.ts
示例4: it
it('should return unmuted dappIds array in peer obj without height', () => {
const expectedPeer = {
broadhash: '',
clock : '',
dappid : ['dappId', 'dappId2'],
height : '',
ip : '127.0.0.1',
nonce : '',
os : '',
port : 1010,
state : 2,
updated : '',
version : '',
};
peer.dappid = ['dappId', 'dappId2'];
const normalized = instance.normalize(Object.assign({}, peer));
expect(parseIntSpy.calledTwice).to.be.true;
expect(parseIntSpy.firstCall.args.length).to.equal(2);
expect(parseIntSpy.firstCall.args[0]).to.equal(peer.port);
expect(parseIntSpy.firstCall.args[1]).to.equal(0);
expect(parseIntSpy.getCall(1).args.length).to.equal(2);
expect(parseIntSpy.getCall(1).args[0]).to.equal(peer.state);
expect(parseIntSpy.getCall(1).args[1]).to.equal(PeerState.DISCONNECTED);
expect(normalized).to.deep.equal(expectedPeer);
});
开发者ID:RiseVision,项目名称:rise-node,代码行数:28,代码来源:peer.spec.ts
示例5: expect
.then(([result, response, descriptor]) => {
// promise results
expect(result).to.be.instanceof(FragmentResult);
expect(result.data).to.deep.equal([{ id: 1, name: 'FOO JOE' }]);
expect(response).to.have.all.keys([
'code',
'config',
'data',
'headers',
'request',
'status',
'statusText'
]);
expect(descriptor).to.equal(spyStore_touchResource.getCall(0).args[0]);
// hooks
expect(spyMutableUsers_generateDescriptor.callCount).to.equal(1);
expect(spyStore_touchResource.callCount).to.equal(1);
expect(spyStore_touchResource.getCall(0).args[0]).to.deep.match(expectedDescriptor);
expect(spyStore_updateResource.callCount).to.equal(1);
expect(spyStore_updateResource.getCall(0).args[1]).to.deep.equal({
id: responseData.id,
name: responseData.name.toUpperCase()
});
expect(spyStore_destroyResource.callCount).to.equal(0);
}, () => {
开发者ID:netarc,项目名称:refrax,代码行数:26,代码来源:mutableResource.spec.ts
示例6: useFakeClock
useFakeClock(clock=>{
cache.get({
numAsString:"5"
});
clock.tick(100);
assert.equal(fetch.getCall(0).args[1], 25, "first static dependency passed in correctly");
assert.equal(fetch.getCall(0).args[2], 3, "second static dependency passed in correctly");
});
开发者ID:agarwalrounak,项目名称:cbioportal-frontend,代码行数:8,代码来源:LazyMobXCache.spec.ts
示例7: onReadySpy
const mockOn = (event: string, cb: (err?: string) => void) => {
if (!doError && event === 'ready') {
onReadySpy();
cb();
} else if (doError && event === 'error') {
onErrorSpy();
cb('testError');
}
};
开发者ID:RiseVision,项目名称:rise-node,代码行数:9,代码来源:cache.spec.ts
示例8: it
it('should invoke default handler when none specified', () => {
const descriptor = new ResourceDescriptor(null, IActionType.get, schema.users.__stack);
processResponse(descriptor, dataCollectionUsers);
expect(spy_defaultHandler.callCount).to.equal(1);
expect(spy_defaultHandler.getCall(0).args[0]).to.equal(descriptor);
expect(spy_defaultHandler.getCall(0).args[1]).to.equal(dataCollectionUsers);
});
开发者ID:netarc,项目名称:refrax,代码行数:9,代码来源:processResponse.spec.ts
注:本文中的Sinon.SinonSpy类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论