mirror of
https://github.com/morluto/rea
synced 2026-10-27 14:42:18 -04:00
4276aaf18b
* feat(signals): discover installed decoders and selected option help * fix(signals): bound retained discovery data and preserve resource failures * fix(signals): complete CLI help and portable decoder patterns * test(signals): verify case-insensitive decoder help queries * fix(signals): retain discovery operation across cleanup retries
49 lines
1.5 KiB
TypeScript
49 lines
1.5 KiB
TypeScript
import { expect, it } from "vitest";
|
|
import { inspectSignalDecodersInputSchema } from "../../../src/domain/signals/signalDecoders.js";
|
|
import { parseDecoderDiscovery } from "../../../src/signals/parseDecoderDiscovery.js";
|
|
|
|
it("rejects malformed catalogs and the wrong decoder identity", () => {
|
|
for (const text of [
|
|
"",
|
|
"Supported protocol decoders:\n",
|
|
"Supported protocol decoders:\n uart UART\n uart Duplicate",
|
|
"Supported protocol decoders:\n malformed",
|
|
]) {
|
|
expect(() =>
|
|
parseDecoderDiscovery(text, inspectSignalDecodersInputSchema.parse({})),
|
|
).toThrow();
|
|
}
|
|
expect(() =>
|
|
parseDecoderDiscovery(
|
|
"ID: spi\nOptions:",
|
|
inspectSignalDecodersInputSchema.parse({ decoder: "uart" }),
|
|
),
|
|
).toThrow();
|
|
});
|
|
|
|
it("keeps help line ordinals, blank lines and literal special characters through selection", () => {
|
|
const text = "ID: uart\r\nOptions:\r\n\r\n- mode: A[0] (default 'x')\r\n";
|
|
const result = parseDecoderDiscovery(
|
|
text,
|
|
inspectSignalDecodersInputSchema.parse({
|
|
decoder: "uart",
|
|
query: "[0]",
|
|
offset: 0,
|
|
limit: 1,
|
|
}),
|
|
);
|
|
expect(result.help_lines).toEqual([
|
|
{ line_number: 4, text: "- mode: A[0] (default 'x')" },
|
|
]);
|
|
expect(result.output_window.examined).toBe(4);
|
|
});
|
|
|
|
it("bounds line expansion before constructing help records", () => {
|
|
expect(() =>
|
|
parseDecoderDiscovery(
|
|
"ID: uart\n" + "\n".repeat(65536),
|
|
inspectSignalDecodersInputSchema.parse({ decoder: "uart" }),
|
|
),
|
|
).toThrow("representation budget");
|
|
});
|