АРЧ АП11 - Архитектура: вынести reply packaging из composeStage в отдельный owner
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
|
||||
import {
|
||||
finalizeComposeReplyResult,
|
||||
inferAddressReplyType,
|
||||
joinComposeReplyLines
|
||||
} from "../src/services/address_runtime/replyPackaging";
|
||||
|
||||
describe("replyPackaging", () => {
|
||||
it("joins reply lines without changing their order", () => {
|
||||
expect(joinComposeReplyLines(["Первая строка", "Вторая строка"])).toBe("Первая строка\nВторая строка");
|
||||
});
|
||||
|
||||
it("applies numeric emphasis line-by-line only when requested", () => {
|
||||
const result = finalizeComposeReplyResult(
|
||||
{
|
||||
responseType: "FACTUAL_SUMMARY",
|
||||
text: "Сумма 1500\nОстаток 22",
|
||||
semantics: { result_mode: "aggregate" }
|
||||
},
|
||||
{
|
||||
emphasizeNumbers: true,
|
||||
emphasizeNumericTokens: (line) => line.replace(/\d+/g, (match) => `**${match}**`)
|
||||
}
|
||||
);
|
||||
|
||||
expect(result.text).toBe("Сумма **1500**\nОстаток **22**");
|
||||
expect(result.semantics).toEqual({ result_mode: "aggregate" });
|
||||
});
|
||||
|
||||
it("keeps reply text unchanged when emphasis is disabled", () => {
|
||||
const result = finalizeComposeReplyResult(
|
||||
{
|
||||
responseType: "FACTUAL_SUMMARY",
|
||||
text: "Сумма 1500"
|
||||
},
|
||||
{
|
||||
emphasizeNumbers: false,
|
||||
emphasizeNumericTokens: () => "не должно примениться"
|
||||
}
|
||||
);
|
||||
|
||||
expect(result.text).toBe("Сумма 1500");
|
||||
});
|
||||
|
||||
it("maps factual response types away from partial coverage", () => {
|
||||
expect(inferAddressReplyType("FACTUAL_LIST")).toBe("factual");
|
||||
expect(inferAddressReplyType("FACTUAL_SUMMARY")).toBe("factual");
|
||||
expect(inferAddressReplyType("SOFT_REFUSAL")).toBe("partial_coverage");
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user