Path: redb-route/vscode-redb-route/src/test/elementposition.test.ts
Snapshot: redb-route, development snapshot 2026-12-06. This is the development state of the public mirrors; it may differ from the published packages.
License: Apache-2.0. Repository: https://github.com/redbase-app/redb-route
Page: https://redbase.app/src/dev-2026-12-06/redb-route/vscode-redb-route/src/test/elementposition.test.ts
----
import { describe, it } from "node:test";
import * as assert from "node:assert/strict";
import { elementPosition } from "../elementposition";
import { withCursor } from "./cursor";
function at(textWithCursor: string) {
const { text, offset } = withCursor(textWithCursor);
return elementPosition(text, offset);
}
describe("elementPosition — where skeletons are allowed", () => {
it("allows element content", () => {
assert.equal(at(`\n |\n`).ok, true);
});
it("allows a half-typed element name and replaces from the <", () => {
const result = at(`\n ', allows the content after it", () => {
assert.equal(at(`\n \n \n |`).ok, true);
});
it("allows a bare < just typed", () => {
assert.equal(at(`\n <|`).ok, true);
});
it("REFUSES the attribute position — the live garbage-insert case", () => {
assert.equal(at(``).ok, false);
});
it("refuses inside an attribute value", () => {
assert.equal(at(``).ok, false);
});
it("refuses inside a comment", () => {
assert.equal(at(`\n`).ok, false);
});
it("refuses inside CDATA", () => {
assert.equal(at(``).ok, false);
});
it("allows content right after a closed tag", () => {
assert.equal(at(`|`).ok, true);
});
});