index.spec.ts 515 B

1234567891011121314151617
  1. import { describe, expect, it } from "@jest/globals";
  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()).toBeCloseTo(nowTime, 2);
  11. });
  12. });