@davidbolaji/termii-node
Version:
Node.js SDK for Termii API – send SMS, voice, OTP, and manage messaging with ease.
31 lines (30 loc) • 1.11 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const EmailTokenService_1 = require("../token/EmailTokenService");
describe("EmailTokenService", () => {
let httpClient;
let service;
beforeEach(() => {
httpClient = { request: jest.fn() };
service = new EmailTokenService_1.EmailTokenService(httpClient);
});
it("sends an email OTP", async () => {
const payload = {
api_key: "key",
email_address: "user@example.com",
code: "1234",
email_configuration_id: "conf1",
};
const mockResponse = {
code: "ok",
message_id: "msg1",
message: "Sent",
balance: 10,
user: "user",
};
httpClient.request.mockResolvedValue(mockResponse);
const result = await service.sendEmailToken(payload);
expect(httpClient.request).toHaveBeenCalledWith("/email/otp/send", expect.objectContaining({ method: "POST", data: payload, authLocation: "body" }));
expect(result).toEqual(mockResponse);
});
});