|
1
|
import { LocalNotificationService } from "../../src/services/local" |
|
2
|
jest.setTimeout(100000) |
|
3
|
|
|
4
|
describe("Local notification provider", () => { |
|
5
|
let localService: LocalNotificationService |
|
6
|
|
|
7
|
beforeAll(() => { |
|
8
|
localService = new LocalNotificationService( |
|
9
|
{ |
|
10
|
logger: console as any, |
|
11
|
}, |
|
12
|
{} |
|
13
|
) |
|
14
|
}) |
|
15
|
|
|
16
|
afterEach(() => { |
|
17
|
jest.restoreAllMocks() |
|
18
|
}) |
|
19
|
|
|
20
|
it("sends logs to the console output with the notification details", async () => { |
|
21
|
const logSpy = jest.spyOn(console, "info") |
|
22
|
await localService.send({ |
|
23
|
to: "test@medusajs.com", |
|
24
|
channel: "email", |
|
25
|
template: "some-template", |
|
26
|
data: { |
|
27
|
username: "john-doe", |
|
28
|
}, |
|
29
|
}) |
|
30
|
|
|
31
|
expect(logSpy).toHaveBeenCalled() |
|
32
|
expect(logSpy).toHaveBeenCalledWith( |
|
33
|
`Attempting to send a notification to: 'test@medusajs.com' on the channel: 'email' with template: 'some-template' and data: '{\"username\":\"john-doe\"}'` |
|
34
|
) |
|
35
|
}) |
|
36
|
}) |