@@ -7,6 +7,15 @@ const { HamLib } = require('../index.js');
77
88console . log ( '🧪 测试node-hamlib模块加载和基础功能...\n' ) ;
99
10+ // 输出Hamlib版本信息
11+ try {
12+ const hamlibVersion = HamLib . getHamlibVersion ( ) ;
13+ console . log ( '📌 Hamlib版本信息:' ) ;
14+ console . log ( ` ${ hamlibVersion } \n` ) ;
15+ } catch ( e ) {
16+ console . log ( '⚠️ 无法获取Hamlib版本信息:' , e . message , '\n' ) ;
17+ }
18+
1019let testsPassed = 0 ;
1120let testsFailed = 0 ;
1221
3443
3544 // 2. 静态方法测试
3645 console . log ( '\n📊 静态方法测试:' ) ;
46+ test ( 'getHamlibVersion静态方法存在' , ( ) => typeof HamLib . getHamlibVersion === 'function' ) ;
3747 test ( 'getSupportedRigs静态方法存在' , ( ) => typeof HamLib . getSupportedRigs === 'function' ) ;
38-
48+
3949 try {
4050 const supportedRigs = HamLib . getSupportedRigs ( ) ;
4151 test ( 'getSupportedRigs返回数组' , ( ) => Array . isArray ( supportedRigs ) ) ;
4656 return first . rigModel && first . modelName && first . mfgName ;
4757 } ) ;
4858 console . log ( ` 📈 找到 ${ supportedRigs . length } 个支持的电台型号` ) ;
59+
60+ // 打印所有支持的设备型号
61+ console . log ( '\n📻 所有支持的设备型号:' ) ;
62+ console . log ( ' ────────────────────────────────────────────────────────────────' ) ;
63+ console . log ( ' 型号ID | 制造商 | 型号名称 | 状态' ) ;
64+ console . log ( ' ────────────────────────────────────────────────────────────────' ) ;
65+ supportedRigs . forEach ( ( rig , index ) => {
66+ const model = String ( rig . rigModel ) . padEnd ( 7 ) ;
67+ const mfg = ( rig . mfgName || '' ) . substring ( 0 , 20 ) . padEnd ( 20 ) ;
68+ const name = ( rig . modelName || '' ) . substring ( 0 , 28 ) . padEnd ( 28 ) ;
69+ const status = rig . status || '' ;
70+ console . log ( ` ${ model } | ${ mfg } | ${ name } | ${ status } ` ) ;
71+
72+ // 每50行输出一个分隔符,便于阅读
73+ if ( ( index + 1 ) % 50 === 0 && index + 1 < supportedRigs . length ) {
74+ console . log ( ' ────────────────────────────────────────────────────────────────' ) ;
75+ }
76+ } ) ;
77+ console . log ( ' ────────────────────────────────────────────────────────────────' ) ;
78+ console . log ( ` 共计: ${ supportedRigs . length } 个型号\n` ) ;
79+
4980 } catch ( e ) {
5081 console . log ( `❌ getSupportedRigs调用失败: ${ e . message } ` ) ;
5182 testsFailed ++ ;
92123 const totalMethods = instanceMethods . length + staticMethods . length ;
93124
94125 test ( `实例方法数量正确 (80个)` , ( ) => instanceMethods . length === 80 ) ;
95- test ( `静态方法数量正确 (1个 )` , ( ) => staticMethods . length === 1 ) ;
96- test ( `总方法数量正确 (81个 )` , ( ) => totalMethods === 81 ) ;
97-
126+ test ( `静态方法数量正确 (2个 )` , ( ) => staticMethods . length === 2 ) ;
127+ test ( `总方法数量正确 (82个 )` , ( ) => totalMethods === 82 ) ;
128+
98129 console . log ( ` 📊 实例方法: ${ instanceMethods . length } 个` ) ;
99130 console . log ( ` 📊 静态方法: ${ staticMethods . length } 个` ) ;
100131 console . log ( ` 📊 总计: ${ totalMethods } 个方法` ) ;
0 commit comments