39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import assert from 'node:assert/strict';
|
|
import test from 'node:test';
|
|
import { spawnSync } from 'node:child_process';
|
|
|
|
import { analyzeTdxRows, parseArguments } from './market-structure-capability.mjs';
|
|
|
|
test('帮助信息声明固定的本机数据源边界', () => {
|
|
const result = spawnSync(
|
|
process.execPath,
|
|
['tools/probes/market-structure-capability.mjs', '--help'],
|
|
{
|
|
cwd: new URL('../..', import.meta.url),
|
|
encoding: 'utf8',
|
|
},
|
|
);
|
|
|
|
assert.equal(result.status, 0);
|
|
assert.match(result.stdout, /127\.0\.0\.1:8080/);
|
|
assert.match(result.stdout, /只读/);
|
|
});
|
|
|
|
test('TDX 列式序列在 Date 与 Amount 等长且分钟时间戳完整时标记为对齐', () => {
|
|
assert.deepEqual(
|
|
analyzeTdxRows({
|
|
Date: ['2026-08-25 09:30:00', '2026-08-25 09:35:00'],
|
|
Amount: ['10', '12'],
|
|
}),
|
|
{ dateAmountAligned: true, timestampsIntraday: true },
|
|
);
|
|
});
|
|
|
|
test('探针拒绝非回环地址和错误端口', () => {
|
|
assert.throws(
|
|
() => parseArguments(['--base-url', 'http://192.168.1.10:8080']),
|
|
/127\.0\.0\.1:8080/,
|
|
);
|
|
assert.throws(() => parseArguments(['--base-url', 'http://127.0.0.1:9000']), /127\.0\.0\.1:8080/);
|
|
});
|