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


TypeScript SinonFakeTimers.restore方法代码示例

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


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

示例1: afterEach

 afterEach(async () => {
     clock.restore();
     await nsp
         .delete()
         .key('connection')
         .exec();
 });
开发者ID:WatchBeam,项目名称:discord-sync,代码行数:7,代码来源:locking.test.ts

示例2: afterEach

				afterEach((): void => {
					if (scenario.today) {
						clock.restore();
					}
				});
开发者ID:scottohara,项目名称:tvmanager,代码行数:5,代码来源:episode-model_spec.ts

示例3: registerSuite

registerSuite('lib/channels/WebSocket', function() {
  class MockWebSocket {
    addEventListener(name: string, callback: (event: any) => void) {
      if (!eventListeners[name]) {
        eventListeners[name] = [];
      }
      eventListeners[name].push(callback);
    }

    send(data: string) {
      sentData.push(data);
    }
  }

  let removeMocks: () => void;
  let eventListeners: { [name: string]: ((event: any) => void)[] };
  let sentData: string[];
  let clock: SinonFakeTimers;

  return {
    before() {
      return mockRequire(require, 'src/lib/channels/WebSocket', {
        'src/lib/browser/util': { parseUrl },
        '@theintern/common': { global: { WebSocket: MockWebSocket }, Task }
      }).then(handle => {
        removeMocks = handle.remove;
        WebSocket = handle.module.default;
      });
    },

    after() {
      removeMocks();
    },

    beforeEach() {
      eventListeners = {};
      sentData = [];
      clock = useFakeTimers();
    },

    afterEach() {
      clock.restore();
    },

    tests: {
      'required args'() {
        assert.throws(() => {
          new WebSocket({ sessionId: 'foo', url: 'bar' });
        }, /port is required/);
      },

      '#sendMessage': {
        good() {
          const ws = new WebSocket({
            sessionId: 'foo',
            url: 'bar',
            port: 12345
          });
          assert.lengthOf(eventListeners['message'], 1);
          assert.lengthOf(eventListeners['open'], 1);
          // There are 2 error handlers, one for the initial
          // connection and one for later errors
          assert.lengthOf(eventListeners['error'], 2);

          // Send an open event to the socket so sendMessage will
          // proceed
          eventListeners['open'][0]({});

          const sent = ws.sendMessage('remoteStatus', 'foo');
          let messageId: string;

          return Promise.resolve()
            .then(() => {
              assert.lengthOf(sentData, 1);
              const message = JSON.parse(sentData[0]);
              messageId = message.id;

              // Send a response
              eventListeners['message'][0]({
                data: JSON.stringify({
                  id: messageId,
                  data: 'bar'
                })
              });

              return sent;
            })
            .then(response => {
              assert.deepEqual(response, {
                id: messageId,
                data: 'bar'
              });
            });
        },

        error() {
          const ws = new WebSocket({
            sessionId: 'foo',
            url: 'bar',
            port: 12345
//.........这里部分代码省略.........
开发者ID:edhager,项目名称:intern,代码行数:101,代码来源:WebSocket.ts

示例4: afterEach

		afterEach((): void => {
			swWrapper.remove();
			clock.restore();
		});
开发者ID:scottohara,项目名称:tvmanager,代码行数:4,代码来源:episode-controller_spec.ts

示例5: afterEach

 afterEach(() => {
   clock.restore();
 });
开发者ID:Ruddickmg,项目名称:js-wars,代码行数:3,代码来源:timedIterator.spec.ts

示例6: afterEach

 afterEach(() => {
   clock.restore();
   typewriter.reset();
 });
开发者ID:Ruddickmg,项目名称:js-wars,代码行数:4,代码来源:typing.spec.ts


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