index.ts 499 B

12345678910111213141516
  1. import { expect } from 'chai';
  2. import { Client } from '../../../../src/models/client';
  3. import { HeartbeatHandler } from '../../../../src/messageHandler/handlers';
  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. });