38 lines
1.2 KiB
TypeScript
38 lines
1.2 KiB
TypeScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
|
|
test('hanbank provider posts the internal SMS API payload shape', async () => {
|
|
process.env.ACS_SMS_PROVIDER = 'hanbank';
|
|
process.env.ACS_SMS_API_URL = 'http://sms.example.test:8000';
|
|
|
|
const calls: Array<{ input: string | URL | Request; init?: RequestInit }> = [];
|
|
const originalFetch = globalThis.fetch;
|
|
globalThis.fetch = (async (input, init) => {
|
|
calls.push({ input, init });
|
|
return new Response(JSON.stringify({ statusCode: '202', statusName: 'success' }), {
|
|
status: 200,
|
|
headers: { 'content-type': 'application/json' },
|
|
});
|
|
}) as typeof fetch;
|
|
|
|
try {
|
|
const { sendSms } = await import('./sms.js');
|
|
const result = await sendSms({
|
|
to: '010-1234-5678',
|
|
text: '[ACS] QR 출입증 링크',
|
|
});
|
|
|
|
assert.equal(result.status, 'SENT');
|
|
assert.equal(result.channel, 'HANBANK');
|
|
assert.equal(String(calls[0]?.input), 'http://sms.example.test:8000/sens/sms');
|
|
assert.deepEqual(JSON.parse(String(calls[0]?.init?.body)), {
|
|
receive_number: '01012345678',
|
|
content: '[ACS] QR 출입증 링크',
|
|
msg_type: 'LMS',
|
|
reserve_time: '',
|
|
});
|
|
} finally {
|
|
globalThis.fetch = originalFetch;
|
|
}
|
|
});
|