From 4fa38554760c4d9a7203c9836ad82141b678ad23 Mon Sep 17 00:00:00 2001 From: Joakim Uddholm Date: Thu, 17 Oct 2024 13:07:28 +0200 Subject: [PATCH] test: make notification test a bit more robust by clearing any previous notifications queued --- core/src/data/threats/ThreatDataService.spec.ts | 1 - core/src/notifications/sender.spec.ts | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/src/data/threats/ThreatDataService.spec.ts b/core/src/data/threats/ThreatDataService.spec.ts index 7fe0ad77..1bddd6cd 100644 --- a/core/src/data/threats/ThreatDataService.spec.ts +++ b/core/src/data/threats/ThreatDataService.spec.ts @@ -1,5 +1,4 @@ import { randomUUID } from "crypto"; -import pg from "pg"; import Control from "../controls/Control.js"; import { DataAccessLayer } from "../dal.js"; import Mitigation from "../mitigations/Mitigation.js"; diff --git a/core/src/notifications/sender.spec.ts b/core/src/notifications/sender.spec.ts index 57038104..bd994e39 100644 --- a/core/src/notifications/sender.spec.ts +++ b/core/src/notifications/sender.spec.ts @@ -38,6 +38,10 @@ describe("notification sender", () => { notificationService = new NotificationDataService(dal); }); + beforeEach(async () => { + await notificationService._truncate(); + }); + afterAll(async () => { await dal.pool.end(); }); @@ -101,6 +105,7 @@ describe("notification sender", () => { const mockFn = (mockedSend as Mock).mockImplementation(async () => true); await notificationService.queue(sampleNotification); + for (let i = 0; i < 3; i++) { await notificationSender( notificationService,