本文整理汇总了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,
}]);
});
示例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");
}
示例3: setTimeout
setTimeout(() => {
if (stub) {
stub();
}
resolve(value);
}, ms);
示例4: mockStub
protected meta<T extends MetaBase>(MetaType: WidgetMetaConstructor<T>): T {
return mockStub(MetaType);
}
示例5: async
'../util/resolve-dir': async (dir: string) => resolveStub(dir),