index.js 516 B

12345678910111213141516
  1. const { expect } = require('chai');
  2. const Client = require('../../../../src/models/client');
  3. const heartbeatHandler = require('../../../../src/messageHandler/handlers/heartbeat');
  4. describe('Heartbeat handler', () => {
  5. it('should update last ping time', () => {
  6. const client = new Client({ id: 'id', token: '' });
  7. client.setLastPing(0);
  8. const nowTime = new Date().getTime();
  9. heartbeatHandler(client);
  10. expect(client.getLastPing()).to.be.closeTo(nowTime, 2);
  11. });
  12. });