本文整理汇总了TypeScript中Sinon.SinonStub.returns方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonStub.returns方法的具体用法?TypeScript SinonStub.returns怎么用?TypeScript SinonStub.returns使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Sinon.SinonStub
的用法示例。
在下文中一共展示了SinonStub.returns方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。
示例1: beforeEach
beforeEach(() => {
resolveStub = sinon.stub();
makeStub = sinon.stub();
publisherSpy = sinon.stub();
voidStub = sinon.stub();
nowhereStub = sinon.stub();
publishers = ['@electron-forge/publisher-test'];
const fakePublisher = (stub: SinonStub) => class {
private publish: SinonStub;
constructor() {
this.publish = stub;
}
};
publish = proxyquire.noCallThru().load('../../src/api/publish', {
'./make': async (...args: any[]) => makeStub(...args),
'../util/resolve-dir': async (dir: string) => resolveStub(dir),
'../util/read-package-json': {
readMutatedPackageJson: () => Promise.resolve(require('../fixture/dummy_app/package.json')),
},
'../util/forge-config': async () => {
const config = await (require('../../src/util/forge-config').default(path.resolve(__dirname, '../fixture/dummy_app')));
config.publishers = publishers;
return config;
},
'@electron-forge/publisher-test': fakePublisher(publisherSpy),
void: fakePublisher(voidStub),
nowhere: fakePublisher(nowhereStub),
}).default;
publisherSpy.returns(Promise.resolve());
resolveStub.returns(path.resolve(__dirname, '../fixture/dummy_app'));
makeStub.returns([]);
});
示例2: stub
'status codes call process exit': (function () {
let processExitStub: SinonStub;
return {
'beforeEach'() {
processExitStub = stub(process, 'exit');
},
'afterEach'() {
processExitStub.restore();
},
async 'Should not exit process if no status code is returned'() {
defaultRunStub.returns(Promise.reject(new Error(errorMessage)));
await yargsStub.command.firstCall.args[ 3 ]({ '_': [ 'group' ] });
assert.isFalse(processExitStub.called);
},
async 'Should exit process if status code is returned'() {
defaultRunStub.returns(Promise.reject({
message: errorMessage,
exitCode: 1
}));
await yargsStub.command.firstCall.args[ 3 ]({ '_': [ 'group' ] });
assert.isTrue(processExitStub.called);
}
};
})()
示例3: it
it('should call getResponse and return', async () => {
getResStub.returns('success');
findOneStub.returns({blockId: '123456'});
genBBStub.callsFake((a) => a);
const ret = await instance.getBlocksCommon('1,2,3', req);
expect(getResStub.calledOnce).to.be.true;
expect(getResStub.firstCall.args).to.be.deep
.equal([{common: {blockId: '123456'}}, 'transportBlocks', 'commonBlock']);
expect(ret).to.be.equal('success');
});
示例4: it
it('should call getSnapshotRounds once or twice', async () => {
getSnapshotRoundsStub.returns(0);
await doCall();
expect(getSnapshotRoundsStub.calledOnce).to.be.true;
getSnapshotRoundsStub.reset();
getSnapshotRoundsStub.returns(12);
dbHelpersStub.enqueueResponse('performOps', Promise.resolve());
await doCall();
expect(getSnapshotRoundsStub.calledTwice).to.be.true;
});
示例5: it
it('should not insert the peer and call logger.debug if this.acceptable([thePeer]) returns empty array', () => {
existsStub.returns(false);
acceptableStub.returns([]);
instance.upsert(peerLogicStub, false);
expect(createStub.calledOnce).to.equal(true);
expect(createStub.firstCall.args[0]).to.deep.equal(peerLogicStub);
expect(loggerStub.stubs.debug.calledOnce).to.equal(true);
expect(loggerStub.stubs.debug.firstCall.args.length).to.equal(2);
expect(loggerStub.stubs.debug.firstCall.args[0]).to.equal('Rejecting unacceptable peer');
expect((instance as any).peers).to.be.deep.equal({});
});