Service implement api or sdk of 3rd party.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 

32 lines
1.0 KiB

'use strict';
const test = require('node:test');
const assert = require('node:assert');
const {default: aliyunSmsClient} = require('../aliyunSmsClient');
const {default: defaultConfig, getCustomConfigs: getCustomConfigs} = require('../conf/config');
test('Custom config load test', async (t) => {
console.log('Config data', defaultConfig);
assert.equal(defaultConfig.ALIBABA_CLOUD_ACCESS_KEY_ID, '你的AccessKey ID');
let myConfig = await getCustomConfigs('./conf/custom_config.json');
console.log('Custom config data', myConfig);
assert.ok(myConfig);
});
test('AliyunSmsClient test', async (t) => {
let myConfig = await getCustomConfigs('./conf/custom_config.json');
let client = aliyunSmsClient.createClient(myConfig);
assert.ok(client);
let signName = 'Ta荐',
templateCode = 'SMS_465915662',
templateParam = '{"code":"2345"}',
phoneNumber = '13168946847';
let sended = await aliyunSmsClient.send(myConfig, signName, templateCode, templateParam, phoneNumber);
assert.equal(sended, true);
});