本文整理汇总了TypeScript中Sinon.SinonSandbox.spy方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonSandbox.spy方法的具体用法?TypeScript SinonSandbox.spy怎么用?TypeScript SinonSandbox.spy使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonSandbox
的用法示例。
在下文中一共展示了SinonSandbox.spy方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
logFileFake = {};
logFileFake.write = () => true;
logFileWriteSpy = sandbox.spy(logFileFake, 'write');
fsStub = sandbox.stub(fs, 'createWriteStream').returns(logFileFake);
consoleLogSpy = sandbox.spy(console, 'log');
});
示例2: it
it('should call String.toLowercase.trim', async () => {
const toLowercaseSpy = sandbox.spy(String.prototype, 'toLowerCase');
const trimSpy = sandbox.spy(String.prototype, 'trim');
await instance.verify(tx, sender);
expect(toLowercaseSpy.calledTwice).to.be.true;
expect(trimSpy.calledOnce).to.be.true;
toLowercaseSpy.restore();
trimSpy.restore();
});
示例3: beforeEach
beforeEach(() => {
container = createContainer();
container.bind(Symbols.api.utils.attachPeerHeaderToResponseObject).to(AttachPeerHeaders);
sandbox = sinon.createSandbox();
response = {set: () => true};
responseSpy = sandbox.spy(response, 'set');
request = {};
next = sandbox.spy();
instance = container.get(Symbols.api.utils.attachPeerHeaderToResponseObject);
});
示例4: it
it('should call firstInRound and lastInRound', () => {
const firstInRoundSpy = sandbox.spy(instance, 'firstInRound');
const lastInRoundSpy = sandbox.spy(instance, 'lastInRound');
instance.heightFromRound(round);
expect(firstInRoundSpy.calledOnce).to.be.true;
expect(lastInRoundSpy.calledOnce).to.be.true;
expect(firstInRoundSpy.firstCall.args[0]).to.be.equal(round);
expect(lastInRoundSpy.firstCall.args[0]).to.be.equal(round);
firstInRoundSpy.restore();
lastInRoundSpy.restore();
});
示例5: beforeEach
beforeEach(() => {
sandbox = sinon.createSandbox();
loggerFake = { log: () => true };
loggerSpy = sandbox.spy(loggerFake, 'log');
req = { method: 'aaa', url: 'bbb', ip: '80.3.10.20' };
sendObject = { send: () => () => true };
sendSpy = sandbox.spy(sendObject, 'send');
res = { setHeader: () => true, status: () => sendObject };
setHeaderSpy = sandbox.spy(res, 'setHeader');
statusSpy = sandbox.spy(res, 'status');
next = sandbox.stub().returns(123);
});
示例6: constructor
constructor() {
const orig = new BlocksModule();
this.lastReceipt = orig.lastReceipt;
this.sandbox = sinon.createSandbox();
this.spies = {
lastReceipt: {
get : this.sandbox.spy(this.lastReceipt, 'get'),
isStale: this.sandbox.spy(this.lastReceipt, 'isStale'),
update : this.sandbox.spy(this.lastReceipt, 'update'),
},
};
}
示例7: beforeEach
beforeEach(() => {
container = createContainer();
container.bind(Symbols.api.utils.errorHandler).to(APIErrorHandler);
sandbox = sinon.createSandbox();
sendSpy = {send: sandbox.spy()};
response = {status: () => sendSpy, send: sendSpy.send };
responseStatusSpy = sandbox.spy(response, 'status');
request = {url: {startsWith: sandbox.stub().callsFake((start) => !(start === '/v2') ) }};
requestStub = request.url.startsWith;
next = sandbox.spy();
loggerStub = container.get(Symbols.helpers.logger);
instance = container.get(Symbols.api.utils.errorHandler);
});
示例8: it
it('should call removeUnconfirmedTransaction when a tx is expired and has not signatures', async () => {
await addMixedTransactionsAndFillPool(true);
const removeUnconfirmedTransactionSpy = sandbox.spy(instance as any, 'removeUnconfirmedTransaction');
instance.expireTransactions();
expect(removeUnconfirmedTransactionSpy.called).to.be.true;
expect(removeUnconfirmedTransactionSpy.callCount).to.be.equal(13);
});
示例9: beforeEach
beforeEach(() => {
fakeApp = {
options: sandbox.stub(),
use : sandbox.stub(),
};
(expressRunner as any).static = sandbox.stub().returns('static');
(fakeBodyParser as any).raw = sandbox.stub().returns('raw');
(fakeBodyParser as any).urlencoded = sandbox.stub().returns('urlencoded');
(fakeBodyParser as any).json = sandbox.stub().returns('json');
fakeMiddleware.logClientConnections = sandbox.stub().returns('logClientConnections');
fakeMiddleware.attachResponseHeader = sandbox.stub().returns('attachResponseHeader');
fakeMiddleware.applyAPIAccessRules = sandbox.stub().returns('applyAPIAccessRules');
fakeMiddleware.protoBuf = sandbox.stub().returns('protoBuf');
applyExpressLimitsStub = sandbox.stub();
compressionStub = sandbox.stub().returns('compression');
corsStub = sandbox.stub().returns('cors');
useContainerForHTTPStub = sandbox.stub();
useExpressServerStub = sandbox.stub();
getMetadataSpy = sandbox.spy(Reflect, 'getMetadata');
containerStub = new ContainerStub(sandbox);
containerStub.get.callsFake((s) => (s === Symbols.generic.expressApp) ? fakeApp : s.toString());
instance = new ProxyAppManager.AppManager(appConfig, loggerStub, '1.0', genesisBlock, constants, []);
(instance as any).container = containerStub;
});