Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
it('triggers ready callback on load', () => {
const readySpy = spy()
recordCore.whenReady(null, readySpy)
assert.calledOnce(readySpy)
assert.calledWithExactly(readySpy, null)
})
}).catch((e) => {
assert.calledOnce(discoverDeviceSpy);
expect(e).to.exist;
miniDroneService.discoverDevice.restore();
noble.on.restore();
done();
});
});
}).catch((e) => {
assert.calledOnce(serviceSpy);
assert.calledOnce(serviceStub);
expect(e).to.exist;
miniDroneService.sendNavCommand.restore();
charList[10].write.restore();
done();
});
});
}).catch((e) => {
assert.calledOnce(proximitySpy);
assert.calledOnce(onSpy);
assert.calledOnce(rssiStub);
expect(e).to.exist;
done();
});
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)
})
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)
})
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)
})
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)
})
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)
})
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'])
})
})