How to use the sinon.assert.calledOnce 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('triggers ready callback on load', () => {
        const readySpy = spy()
        recordCore.whenReady(null, readySpy)

        assert.calledOnce(readySpy)
        assert.calledWithExactly(readySpy, null)
    })
github gandhimonik / DroneJS / test / services / MiniDroneServiceSpec.js View on Github external
}).catch((e) => {
                assert.calledOnce(discoverDeviceSpy);
                expect(e).to.exist;
                miniDroneService.discoverDevice.restore();
                noble.on.restore();
                done();
            });
        });
github gandhimonik / DroneJS / test / services / MiniDroneServiceSpec.js View on Github external
}).catch((e) => {
                assert.calledOnce(serviceSpy);
                assert.calledOnce(serviceStub);
                expect(e).to.exist;
                miniDroneService.sendNavCommand.restore();
                charList[10].write.restore();
                done();
            });
        });
github gandhimonik / DroneJS / test / services / MiniDroneServiceSpec.js View on Github external
}).catch((e) => {
                assert.calledOnce(proximitySpy);
                assert.calledOnce(onSpy);
                assert.calledOnce(rssiStub);
                expect(e).to.exist;
                done();
            });
github deepstreamIO / deepstream.io-client-js / src / record / write-ack-service.spec.ts View on Github external
it('doesn\'t call callback twice', async () => {
      const msg = {
        topic,
        action: RECORD_ACTION.WRITE_ACKNOWLEDGEMENT,
        correlationId,
        originalAction: RECORD_ACTION.CREATEANDUPDATE,
        isWriteAck: true
      }
      writeAckService.recieve(msg)
      writeAckService.recieve(msg)
      await BBPromise.delay(1)

      assert.calledOnce(callbackSpy)
      assert.calledWith(callbackSpy)
    })
github deepstreamIO / deepstream.io-client-js / src / record / record-handler.spec.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], name)
        })
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-client-js / src / record / record-core.spec.ts View on Github external
it('sends patch messages for path changes after when ready', async () => {
        const ackCallback = spy()

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

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

        await BBPromise.delay(0)

        assert.calledOnce(ackCallback)
        assert.calledWithExactly(ackCallback, EVENT.CLIENT_OFFLINE, name)
    })
github deepstreamIO / deepstream.io-client-js / src / connection / connection.spec.ts View on Github external
it('goes into limbo on connection lost', async () => {
    await openConnection()
    const limboSpy = spy()

    connection.onExitLimbo(limboSpy)

    await loseConnection()
    expect(connection.isInLimbo).to.equal(true)

    await BBPromise.delay(20)

    assert.calledOnce(limboSpy)
    expect(connection.isInLimbo).to.equal(false)
  })
github silversonicaxel / summary-more / src / class / maker.spec.ts View on Github external
it('should read documents from folder', async () => {
      sandboxSet.stub(maker, 'readSummaryFile').returns('Some content')
      const readFilesFromFolderStub = sandboxSet.stub(maker, 'readFilesFromFolder')
      await maker.applySummaryMore(baseFolder, docsFolder, docsSection)

      assert.calledOnce(readFilesFromFolderStub)
      assert.calledWith(readFilesFromFolderStub, maker['summaryDocumentationFolder'], maker['updateSummaryFile'])
    })
  })