mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 06:57:41 +00:00
refactor(shared): reuse outbound text chunking core
This commit is contained in:
16
src/plugin-sdk/text-chunking.test.ts
Normal file
16
src/plugin-sdk/text-chunking.test.ts
Normal file
@@ -0,0 +1,16 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { chunkTextForOutbound } from "./text-chunking.js";
|
||||
|
||||
describe("chunkTextForOutbound", () => {
|
||||
it("returns empty for empty input", () => {
|
||||
expect(chunkTextForOutbound("", 10)).toEqual([]);
|
||||
});
|
||||
|
||||
it("splits on newline or whitespace boundaries", () => {
|
||||
expect(chunkTextForOutbound("alpha\nbeta gamma", 8)).toEqual(["alpha", "beta", "gamma"]);
|
||||
});
|
||||
|
||||
it("falls back to hard limit when no separator exists", () => {
|
||||
expect(chunkTextForOutbound("abcdefghij", 4)).toEqual(["abcd", "efgh", "ij"]);
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user