本文整理汇总了TypeScript中Sinon.spy函数的典型用法代码示例。如果您正苦于以下问题:TypeScript spy函数的具体用法?TypeScript spy怎么用?TypeScript spy使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了spy函数的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: it
it('should call "addModule"', () => {
const addModuleSpy = sinon.spy(container, 'addModule');
container.addDynamicModules([Test] as any, []);
expect(addModuleSpy.called).to.be.true;
});
示例2: beforeEach
beforeEach('setup', () => {
channel = pigeon.channel('a');
channelB = pigeon.channel('b');
cb = sinon.spy();
});
示例3: it
it('should return observable', () => {
const fn = server.createUnaryServiceMethod(sinon.spy());
expect(fn).to.be.a('function');
});
示例4: beforeEach
beforeEach(() => { consoleInfo = spy(console, "info"); });
示例5: beforeEach
beforeEach(() => {
// Listen to console.error calls.
spy = sinon.spy(console, 'error');
});
示例6: registerSuite
if (timerHandle) {
timerHandle.destroy();
timerHandle = null;
}
}
registerSuite('utility functions', {
afterEach() {
destroyTimerHandle();
},
tests: {
createTimer: {
destroy(this: any) {
const dfd = this.async(1000);
const spy = sinon.spy();
timerHandle = util.createTimer(spy, 100);
setTimeout(function () {
destroyTimerHandle();
}, 50);
setTimeout(dfd.callback(function () {
assert.strictEqual(spy.callCount, 0);
}), 110);
},
timeout(this: any) {
const dfd = this.async(1000);
const spy = sinon.spy();
timerHandle = util.createTimer(spy, 100);
示例7: callback
},
'/path/to/second': {
foo: 'bar'
},
'/path/bar': {
bar: 'baz'
},
'/other': {
value: 'The quick brown fox jumped over the lazy dog.'
},
'bundle!lazy'(callback: (value: any) => any) {
callback({ value: 'lazy loaded' });
},
'plugin!normalize': {
normalize: sinon.stub().returns('normalized/path/to/resource'),
load: sinon.spy()
},
'plugin!resource/id': {
load: sinon.spy()
},
'plugin!./resource/id': {
load: sinon.spy()
},
'parent/plugin!./resource/id': {
load: sinon.spy()
}
});
},
afterEach() {
setModules();
示例8: it
it('should create exception handler', () => {
const handlerCreateSpy = sinon.spy(exceptionFiltersContext, 'create');
contextCreator.create(instance, instance.test, module);
expect(handlerCreateSpy.calledWith(instance, instance.test)).to.be.true;
});
示例9: beforeEach
beforeEach(() => {
callback = sinon.spy(console, 'log');
stdoutWriteMock = new StdoutWriteMock(process.stdout.write);
});