How to use the sinon.fake function in sinon

To help you get started, we’ve selected a few sinon examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github voluntarily / vly2 / components / Interest / __tests__ / RegisterInterestItem.spec.js View on Github external
test('invited', t => {
  const changeStatus = sinon.fake()
  const withdraw = sinon.fake()

  const wrapper = mountWithIntl(
    )
  t.is(wrapper.find('h4').first().text(), 'Thank you so much!')
})
github alexryd / node-shellies / test / test-device.js View on Github external
it('should update the host', function() {
      const changeHostHandler = sinon.fake()
      const msg = {
        host: '192.168.1.3',
      }

      device.on('change:host', changeHostHandler)
      device._applyUpdate(msg, [])

      changeHostHandler.calledOnce.should.equal(true)
      changeHostHandler.calledWith(msg.host).should.equal(true)
    })
github alexryd / node-shellies / test / test-shellies.js View on Github external
it('should not emit `stale` when `staleTimeout` is disabled', function() {
    const clock = sinon.useFakeTimers()
    const staleHandler = sinon.fake()
    const deviceStaleHandler = sinon.fake()
    shellies.on('stale', staleHandler)
    device.on('stale', deviceStaleHandler)

    shellies.staleTimeout = 0
    device.online = true
    shellies.addDevice(device)
    device.online = false

    staleHandler.called.should.equal(false)
    clock.tick(99999999999)
    staleHandler.calledOnce.should.equal(false)
    deviceStaleHandler.calledOnce.should.equal(false)

    clock.restore()
  })
github alexryd / node-shellies / test / test-shellies.js View on Github external
it('should emit `discover` when a new device is found', function() {
    const discoverHandler = sinon.fake()
    shellies.on('discover', discoverHandler)

    const msg = {
      deviceType: 'SHSW-1',
      deviceId: 'ABC123',
      host: '192.168.1.2',
    }
    shellies._listener.emit('statusUpdate', msg)

    discoverHandler.calledOnce.should.equal(true)
    discoverHandler.lastCall.args[0].type.should.equal(msg.deviceType)
    discoverHandler.lastCall.args[0].id.should.equal(msg.deviceId)
    discoverHandler.lastCall.args[0].host.should.equal(msg.host)
    discoverHandler.lastCall.args[1].should.be.false()

    const msg2 = {
github alexryd / node-shellies / test / test-shellies.js View on Github external
it('should emit `add` when a new device is discovered', function() {
    const addHandler = sinon.fake()
    shellies.on('add', addHandler)

    const msg = {
      deviceType: 'SHSW-1',
      deviceId: 'ABC123',
      host: '192.168.1.2',
    }
    shellies._listener.emit('statusUpdate', msg)

    addHandler.calledOnce.should.equal(true)
  })
github keymanapp / keyman / common / predictive-text / unit_tests / headless / top-level-lmlayer.js View on Github external
function createFakeWorker(postMessage) {
    return {
        postMessage: postMessage ? sinon.fake(postMessage) : sinon.fake(),
        onmessage: null
      };
  }
github nilzona / path2d-polyfill / test / path2d-polyfill.spec.js View on Github external
beforeEach(() => {
      stroke = sinon.fake();
      fill = sinon.fake();
      sinon.replace(window.CanvasRenderingContext2D.prototype, 'stroke', stroke);
      sinon.replace(window.CanvasRenderingContext2D.prototype, 'fill', fill);
      ctx = new window.CanvasRenderingContext2D();
      polyfillPath2D(window);
    });
github slackapi / bolt / src / App.spec.ts View on Github external
function buildOverrides(secondOverride: Override) {
        fakeReceiver = createFakeReceiver();
        fakeErrorHandler = sinon.fake();
        dummyAuthorizationResult = { botToken: '', botId: '' };
        overrides = mergeOverrides(
          withNoopAppMetadata(),
          secondOverride,
          withMemoryStore(sinon.fake()),
          withConversationContext(sinon.fake.returns(noopMiddleware))
        );
        return overrides;
      }
github elastic / kibana / src / legacy / ui / public / new_platform / new_platform.karma_mock.js View on Github external
},
};

export const npStart = {
  core: {
    chrome: {},
  },
  plugins: {
    embeddable: {
      getEmbeddableFactory: sinon.fake(),
      getEmbeddableFactories: sinon.fake(),
      registerEmbeddableFactory: sinon.fake(),
    },
    expressions: {
      registerFunction: sinon.fake(),
      registerRenderer: sinon.fake(),
      registerType: sinon.fake(),
    },
    data: {
      getSuggestions: sinon.fake(),
    },
    inspector: {
      isAvailable: () => false,
      open: () => ({
        onClose: Promise.resolve(undefined),
        close: () => Promise.resolve(undefined),
      }),
    },
    uiActions: {
      attachAction: sinon.fake(),
      registerAction: sinon.fake(),
      registerTrigger: sinon.fake(),