@davidbolaji/termii-node
Version:
Node.js SDK for Termii API – send SMS, voice, OTP, and manage messaging with ease.
35 lines (34 loc) • 1.22 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
const InAppTokenService_1 = require("../token/InAppTokenService");
describe("InAppTokenService", () => {
let httpClient;
let service;
beforeEach(() => {
httpClient = { request: jest.fn() };
service = new InAppTokenService_1.InAppTokenService(httpClient);
});
it("generates an in-app token", async () => {
const payload = {
api_key: "key",
pin_type: "NUMERIC",
phone_number: "1234567890",
pin_attempts: 3,
pin_time_to_live: 5,
pin_length: 6,
};
const mockResponse = {
status: "success",
data: {
pin_id: "abc123",
otp: "654321",
phone_number: "1234567890",
phone_number_other: "1234567890",
},
};
httpClient.request.mockResolvedValue(mockResponse);
const result = await service.generate(payload);
expect(httpClient.request).toHaveBeenCalledWith("/sms/otp/generate", expect.objectContaining({ method: "POST", data: payload }));
expect(result).toEqual(mockResponse);
});
});