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


TypeScript Sinon.sandbox类代码示例

本文整理汇总了TypeScript中Sinon.sandbox的典型用法代码示例。如果您正苦于以下问题:TypeScript sandbox类的具体用法?TypeScript sandbox怎么用?TypeScript sandbox使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: expect

 const testCase = (belongToSameDrive: boolean) => {
   const sandbox = sinon.sandbox.create();
   sinon.stub(iconGenerator, 'hasCustomIcon').returns(true);
   sandbox.stub(utils, 'belongToSameDrive').returns(belongToSameDrive);
   const json = iconGenerator.generateJson(emptyFileCollection, emptyFolderCollection);
   expect(json.iconDefinitions._file.iconPath)
     .to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
   expect(json.iconDefinitions._folder.iconPath)
     .to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
   expect(json.iconDefinitions._folder_open.iconPath)
     .to.include(iconGenerator.settings.extensionSettings.customIconFolderName);
   sandbox.restore();
 };
开发者ID:jens1o,项目名称:vscode-icons,代码行数:13,代码来源:functionality.test.ts

示例2: beforeEach

    beforeEach(function () {
        BSTVirtualAlexa = function () {
            this.start = function () {
            };
        };

        mockery.enable({ useCleanCache: true, warnOnReplace: false, warnOnUnregistered: false });
        mockery.registerMock("../lib/core/global", globalModule);
        mockery.registerMock("../lib/client/bst-virtual-alexa", {
            BSTVirtualAlexa: BSTVirtualAlexa
        });

        sandbox = sinon.sandbox.create();
    });
开发者ID:bespoken,项目名称:bst,代码行数:14,代码来源:bst-intend-test.ts

示例3: it

 it('should act like the async scheduler if delay > 0', () => {
   let actionHappened = false;
   const sandbox = sinon.sandbox.create();
   const fakeTimer = sandbox.useFakeTimers();
   queue.schedule(() => {
     actionHappened = true;
   }, 50);
   expect(actionHappened).to.be.false;
   fakeTimer.tick(25);
   expect(actionHappened).to.be.false;
   fakeTimer.tick(25);
   expect(actionHappened).to.be.true;
   sandbox.restore();
 });
开发者ID:arliang,项目名称:rxjs,代码行数:14,代码来源:QueueScheduler-spec.ts

示例4: it

 it('should cancel animationFrame actions when unsubscribed', () => {
   let actionHappened = false;
   const sandbox = sinon.sandbox.create();
   const fakeTimer = sandbox.useFakeTimers();
   animationFrame.schedule(() => {
     actionHappened = true;
   }, 50).unsubscribe();
   expect(actionHappened).to.be.false;
   fakeTimer.tick(25);
   expect(actionHappened).to.be.false;
   fakeTimer.tick(25);
   expect(actionHappened).to.be.false;
   sandbox.restore();
 });
开发者ID:DallanQ,项目名称:rxjs,代码行数:14,代码来源:AnimationFrameScheduler-spec.ts

示例5: beforeEach

	beforeEach(() => {
		sandbox = sinon.sandbox.create();
		mockModule = new MockModule('../../src/allCommands', require);
		mockModule.dependencies(['./command', './loadCommands', './config']);
		mockCommand = mockModule.getMock('./command');
		mockLoadCommands = mockModule.getMock('./loadCommands');

		const groupCCommandMap = new Map().set('a', { name: 'a', group: 'c', path: 'as' });
		const groupDCommandMap = new Map().set('b', { name: 'b', group: 'd', path: 'asas' });
		const groupMap = new Map().set('c', groupCCommandMap).set('d', groupDCommandMap);

		mockLoadCommands.loadCommands = sandbox.stub().resolves(groupMap);
		moduleUnderTest = mockModule.getModuleUnderTest();
	});
开发者ID:dojo,项目名称:cli,代码行数:14,代码来源:allCommands.ts

示例6: proxyquire

test.beforeEach(t => {
  const sandbox = sinon.sandbox.create();
  const go = sandbox.stub();
  const start = sandbox.stub();
  const History = sandbox.stub();
  History.prototype.go = go;
  History.prototype.start = start;
  t.context.go = go;
  t.context.start = start;
  t.context.History = History;
  t.context.init = proxyquire('../src/', {
    './history': { History }
  }).init;
});
开发者ID:bouzuya,项目名称:boa-handler-history,代码行数:14,代码来源:index.ts

示例7: it

  it('should console.log events when given a string', (done) => {
    const sandbox = sinon.sandbox.create()
    sandbox.spy(console, 'log')

    const stream = debug('Stream', Stream.of(1))
    const expected = [1]

    stream.subscribe((x) => {
      assert(x === expected.shift())
    }, done, () => {
      sinon.assert.calledTwice(console.log as Sinon.SinonSpy)
      sandbox.restore()
      done()
    })
  })
开发者ID:TylorS,项目名称:tempest,代码行数:15,代码来源:index.ts

示例8: beforeEach

 beforeEach(() => {
   instance = Weather();
   sandbox = sinon.sandbox.create();
   if (typeof window === 'undefined') {
     (global as any).window = global;
   }
   if (window.fetch === undefined) {
     window.fetch = function () { } as any;
   }
   sandbox.stub(window, 'fetch', () => new Promise((resolve, reject) => {
     resolveFetch = resolve;
     rejectFetch = reject;
   }));
   return zurvan.interceptTimers().catch(() => { });
 });
开发者ID:SMH110,项目名称:widgets,代码行数:15,代码来源:weather.spec.ts

示例9: beforeEach

 beforeEach(() => {
   runnerOptions = {
     port: 42,
     files: [],
     strykerOptions: null
   };
   sinonSandbox = sinon.sandbox.create();
   fakeChildProcess = {
     kill: sinon.spy(),
     send: sinon.spy(),
     on: sinon.spy()
   }
   sinonSandbox.stub(child_process, 'fork', () => fakeChildProcess);
   clock = sinon.useFakeTimers();
 });
开发者ID:devlucas,项目名称:stryker,代码行数:15,代码来源:IsolatedTestRunnerAdapterSpec.ts

示例10: it

 it('should return a dispose function', function() {
   let sandbox = sinon.sandbox.create();
   const spy = sandbox.spy();
   function app(sources: any): any {
     return {
       other: sources.other.take(1).startWith('a'),
     };
   }
   function driver() {
     return Rx.Observable.of('b').do(spy);
   }
   let dispose = run(app, {other: driver});
   assert.strictEqual(typeof dispose, 'function');
   sinon.assert.calledOnce(spy);
   dispose();
 });
开发者ID:joeldentici,项目名称:cyclejs,代码行数:16,代码来源:index.ts


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