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


TypeScript SinonStub.default方法代码示例

本文整理汇总了TypeScript中Sinon.SinonStub.default方法的典型用法代码示例。如果您正苦于以下问题:TypeScript SinonStub.default方法的具体用法?TypeScript SinonStub.default怎么用?TypeScript SinonStub.default使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sinon.SinonStub的用法示例。


在下文中一共展示了SinonStub.default方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的TypeScript代码示例。

示例1: it

  it('should call the provided publisher with the appropriate args', async () => {
    makeStub.returns([{ artifacts: ['artifact1', 'artifact2'] }]);
    await publish({
      dir: __dirname,
      interactive: false,
      // Fake instance of a publisher
      publishTargets: [{
        __isElectronForgePublisher: true,
        publish: publisherSpy,
        platforms: null,
      } as any],
    });
    expect(publisherSpy.callCount).to.equal(1);
    // pluginInterface will be a new instance so we ignore it
    delete publisherSpy.firstCall.args[0].forgeConfig.pluginInterface;
    const testConfig = await require('../../src/util/forge-config').default(path.resolve(__dirname, '../fixture/dummy_app'));

    testConfig.publishers = publishers;

    delete testConfig.pluginInterface;
    expect(publisherSpy.firstCall.args).to.deep.equal([{
      dir: resolveStub(),
      makeResults: [{ artifacts: ['artifact1', 'artifact2'] }],
      forgeConfig: testConfig,
    }]);
  });
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:26,代码来源:publish_spec.ts

示例2: constructor

	public constructor(accountMockProvider: AccountMockProvider, accountsMockProvider: AccountsMockProvider, accountsWithBalancesMockProvider: AccountsWithBalancesMockProvider, $qMockProvider: QMockProvider) {
		/*
		 * Success/error = options for the stub promises
		 * all/allWithBalances =  promise-like responses
		 */
		const success: PromiseMockConfig<{data: Account}> = {
						args: {id: 1},
						response: {data: accountMockProvider.$get()}
					},
					error: PromiseMockConfig<void> = {
						args: {id: -1}
					},
					$q: QMock = $qMockProvider.$get(),
					all: SinonStub = $q.promisify({
						response: accountsMockProvider.$get()
					}),
					allWithBalances: SinonStub = $q.promisify({
						response: accountsWithBalancesMockProvider.$get()
					});

		// Configure the different responses for all()
		all.withArgs(true).returns(allWithBalances());

		// Mock accountModel object
		this.accountModel = {
			recent: "recent accounts list",
			type: "account",
			path(id: number): string {
				return `/accounts/${id}`;
			},
			all: sinon.stub().returns(all()),
			allWithBalances: sinon.stub().returns(all(true)),
			find(id: number): SinonStub {
				// Get the matching account
				const account: Account = accountsMockProvider.$get()[id - 1];

				// Return a promise-like object that resolves with the account
				return $q.promisify({response: account})();
			},
			save: $q.promisify(success, error),
			destroy: $q.promisify(success, error),
			reconcile: $q.promisify(),
			toggleFavourite(account: Account): SinonStub {
				return $q.promisify({response: !account.favourite})();
			},
			isUnreconciledOnly: sinon.stub().returns(true),
			unreconciledOnly: sinon.stub(),
			flush: sinon.stub(),
			addRecent: sinon.stub(),
			accounts: accountsWithBalancesMockProvider.$get()
		};

		// Spy on find() and toggleFavourite()
		sinon.spy(this.accountModel, "find");
		sinon.spy(this.accountModel, "toggleFavourite");
	}
开发者ID:scottohara,项目名称:loot,代码行数:56,代码来源:account.ts

示例3: setTimeout

 setTimeout(() => {
   if (stub) {
     stub();
   }
   resolve(value);
 }, ms);
开发者ID:RiseVision,项目名称:rise-node,代码行数:6,代码来源:sequence.spec.ts

示例4: mockStub

		protected meta<T extends MetaBase>(MetaType: WidgetMetaConstructor<T>): T {
			return mockStub(MetaType);
		}
开发者ID:mwistrand,项目名称:widgets,代码行数:3,代码来源:test-helpers.ts

示例5: async

 '../util/resolve-dir': async (dir: string) => resolveStub(dir),
开发者ID:balloonzzq,项目名称:electron-forge,代码行数:1,代码来源:publish_spec.ts


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