當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。