2025-04-16 14:16:53 -07:00
|
|
|
|
import TextBuffer from "../src/text-buffer.js";
|
2025-04-16 12:56:08 -04:00
|
|
|
|
import { describe, it, expect } from "vitest";
|
|
|
|
|
|
|
|
|
|
|
|
describe("TextBuffer – newline normalisation", () => {
|
|
|
|
|
|
it("insertStr should split on \r and \r\n sequences", () => {
|
|
|
|
|
|
const buf = new TextBuffer("");
|
|
|
|
|
|
|
|
|
|
|
|
// Windows‑style CRLF
|
|
|
|
|
|
buf.insertStr("ab\r\ncd\r\nef");
|
|
|
|
|
|
|
|
|
|
|
|
expect(buf.getLines()).toEqual(["ab", "cd", "ef"]);
|
|
|
|
|
|
expect(buf.getCursor()).toEqual([2, 2]); // after 'f'
|
|
|
|
|
|
});
|
|
|
|
|
|
});
|