From b9b904a47d57d5c08f88bb9bc57505e6f8dca6af Mon Sep 17 00:00:00 2001 From: "GUANGHUIW\\74777" Date: Mon, 23 Dec 2024 21:00:30 +0800 Subject: [PATCH] fix: fix UT --- .../lib/utils/idle-detection/idle-detection.service.spec.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/projects/ngx-lift/src/lib/utils/idle-detection/idle-detection.service.spec.ts b/projects/ngx-lift/src/lib/utils/idle-detection/idle-detection.service.spec.ts index 8c3b2a0..cecfe31 100644 --- a/projects/ngx-lift/src/lib/utils/idle-detection/idle-detection.service.spec.ts +++ b/projects/ngx-lift/src/lib/utils/idle-detection/idle-detection.service.spec.ts @@ -30,22 +30,24 @@ describe('IdleDetectionService', () => { expect(service['isCountingDown']).toBeFalse(); }); - it('should start countdown after idle end', () => { + it('should start countdown after idle end', (done) => { service.startWatching(); setTimeout( () => { expect(service['isCountingDown']).toBeTrue(); + done(); }, service['idleDuration'] * 1000 + 100, ); }); - it('should stop countdown on user activity during countdown', () => { + it('should stop countdown on user activity during countdown', (done) => { service.startWatching(); setTimeout(() => { const event = new MouseEvent('mousemove'); document.dispatchEvent(event); expect(service['isCountingDown']).toBeFalse(); + done(); }, 3000); });