feat: Add support for sendgrid and logger notification providers (#7290)

* feat: Add support for sendgrid and logger notification providers

* fix: changes based on PR review
This commit is contained in:
Stevche Radevski
2024-05-11 17:40:03 +02:00
committed by GitHub
parent 1a68f4602c
commit 79758c46b6
24 changed files with 631 additions and 1 deletions
@@ -0,0 +1,36 @@
import { LocalNotificationService } from "../../src/services/local"
jest.setTimeout(100000)
describe("Local notification provider", () => {
let localService: LocalNotificationService
beforeAll(() => {
localService = new LocalNotificationService(
{
logger: console as any,
},
{}
)
})
afterEach(() => {
jest.restoreAllMocks()
})
it("sends logs to the console output with the notification details", async () => {
const logSpy = jest.spyOn(console, "info")
await localService.send({
to: "test@medusajs.com",
channel: "email",
template: "some-template",
data: {
username: "john-doe",
},
})
expect(logSpy).toHaveBeenCalled()
expect(logSpy).toHaveBeenCalledWith(
'Attempting to send a notification to: test@medusajs.com on the channel: email with template: some-template and data: {"username":"john-doe"}'
)
})
})