How to use the sinon.assert.calledWithExactly 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 deepstreamIO / deepstream.io-client-js / test / record / record-core-offlineSpec.ts View on Github external
it('sends erase write ack messages for erase after when ready', async () => {
        const ackCallback = spy()

        services.storageMock
        .expects('set')
        .once()
        .withExactArgs(name, 2, {}, match.func)

        recordCore.set({ path: 'firstname', callback: ackCallback })

        await BBPromise.delay(0)

        assert.calledOnce(ackCallback)
        assert.calledWithExactly(ackCallback, EVENT.CLIENT_OFFLINE, name)
    })
github deepstreamIO / deepstream.io-client-js / test / record / record-core-offlineSpec.ts View on Github external
it('triggers ready callback on load', () => {
        const readySpy = spy()
        recordCore.whenReady(null, readySpy)

        assert.calledOnce(readySpy)
        assert.calledWithExactly(readySpy, null)
    })
github deepstreamIO / deepstream.io-client-js / test / record / record-setData-onlineSpec.ts View on Github external
it('calls callbackAck with error', async () => {
      recordHandler.setDataWithAck(name, data, ackCallback)

      handle(errorMsg)
      await BBPromise.delay(1)

      assert.calledOnce(ackCallback)
      assert.calledWithExactly(ackCallback, RECORD_ACTION[errorMsg.action])
    })
github deepstreamIO / deepstream.io-client-js / test / record / record-setData-onlineSpec.ts View on Github external
it('calls callbackAck for setData deleting values', async () => {
      recordHandler.setDataWithAck(name, path, undefined, ackCallback)

      handle(eraseAckMsg)
      await BBPromise.delay(1)

      assert.calledOnce(ackCallback)
      assert.calledWithExactly(ackCallback, null)
    })
github deepstreamIO / deepstream.io-client-js / src / record / record-handler.spec.ts View on Github external
it('handles record not found error messages', async () => {
      handle({
        topic: TOPIC.RECORD,
        action: RECORD_ACTION.HEAD_RESPONSE,
        originalAction: RECORD_ACTION.HEAD,
        version: -1,
        name
      })

      await BBPromise.delay(1)

      assert.calledOnce(callbackSpy)
      assert.calledWithExactly(callbackSpy, null, false)

      assert.calledOnce(resolveSpy)
      assert.calledWithExactly(resolveSpy, false)

      assert.notCalled(rejectSpy)
    })
github deepstreamIO / deepstream.io-client-js / src / presence / presence-handler.spec.ts View on Github external
it('calls query for specific users callback with error message when connection is lost', async () => {
    const users = ['userA', 'userB']
    presenceHandler.getAll(users, callbackSpy)
    const promise = presenceHandler.getAll(users)
    promise.then(promiseSuccess).catch(promiseError)

    services.simulateConnectionLost()
    await BBPromise.delay(1)

    assert.calledOnce(callbackSpy)
    assert.calledWithExactly(callbackSpy, EVENT.CLIENT_OFFLINE)

    assert.notCalled(promiseSuccess)
    assert.calledOnce(promiseError)
    assert.calledWithExactly(promiseError, EVENT.CLIENT_OFFLINE)
  })
github deepstreamIO / deepstream.io / src / services / permission / valve / config-permission-load.spec.ts View on Github external
it('fails to load maxRuleIterations less than zero initialization', async () => {
      const permission = new ConfigPermission({
        permissions: testHelper.getBasePermissions(),
        cacheEvacuationInterval: 60000,
        maxRuleIterations: 0
      }, services, config)

      assert.calledOnce(services.logger.fatal)
      assert.calledWithExactly(services.logger.fatal, EVENT.PLUGIN_INITIALIZATION_ERROR, 'Maximum rule iteration has to be at least one')
    })
github deepstreamIO / deepstream.io-client-js / src / record / record-handler.spec.ts View on Github external
it('calls callbackAck for setData without path', async () => {
          recordHandler.setDataWithAck(name, data, ackCallback)

          handle(createUpdateAckMsg)
          await BBPromise.delay(1)

          assert.calledOnce(ackCallback)
          assert.calledWithExactly(ackCallback, null, name)
        })
github deepstreamIO / deepstream.io-client-js / src / connection / connection.spec.ts View on Github external
it('handles successful authentication', async () => {
    await awaitConnectionAck()
    await sendChallenge()
    await receiveChallengeAccept()
    await sendAuth()
    await receiveAuthResponse()

    assert.calledOnce(authCallback)
    assert.calledWithExactly(authCallback, true, clientData)
  })
github deepstreamIO / deepstream.io-client-js / src / connection / connection.spec.ts View on Github external
emitterMock
      .expects('emit')
      .once()
      .withExactArgs(
        EVENT.CONNECTION_STATE_CHANGED,
        CONNECTION_STATE.AWAITING_AUTHENTICATION
      )

    await awaitConnectionAck()
    await sendChallenge()
    await receiveChallengeAccept()
    await sendAuth()
    await receiveAuthRejectResponse()

    assert.calledOnce(authCallback)
    assert.calledWithExactly(authCallback, false, { reason: EVENT.INVALID_AUTHENTICATION_DETAILS })
  })