当前位置: 首页>>代码示例>>TypeScript>>正文


TypeScript SinonStub.returns方法代码示例

本文整理汇总了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([]);
  });
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:35,代码来源:publish_spec.ts

示例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);
				}
			};
		})()
开发者ID:dylans,项目名称:cli,代码行数:27,代码来源:registerCommands.ts

示例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');
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:10,代码来源:transportV2API.spec.ts

示例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;
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:10,代码来源:rounds.spec.ts

示例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({});
 });
开发者ID:RiseVision,项目名称:rise-node,代码行数:11,代码来源:peers.spec.ts


注:本文中的Sinon.SinonStub.returns方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。