34 lines
926 B
TypeScript
34 lines
926 B
TypeScript
import { describe, expect, it } from "vitest";
|
|
import { parseInlinePathToken } from "./inline-path";
|
|
|
|
describe("parseInlinePathToken", () => {
|
|
it("returns null for plain paths (no line)", () => {
|
|
expect(parseInlinePathToken("src/app.ts")).toBeNull();
|
|
expect(parseInlinePathToken("README.md")).toBeNull();
|
|
});
|
|
|
|
it("parses filename:line", () => {
|
|
expect(parseInlinePathToken("src/app.ts:12")).toEqual({
|
|
raw: "src/app.ts:12",
|
|
path: "src/app.ts",
|
|
lineStart: 12,
|
|
lineEnd: undefined,
|
|
});
|
|
});
|
|
|
|
it("parses filename:lineStart-lineEnd", () => {
|
|
expect(parseInlinePathToken("src/app.ts:12-20")).toEqual({
|
|
raw: "src/app.ts:12-20",
|
|
path: "src/app.ts",
|
|
lineStart: 12,
|
|
lineEnd: 20,
|
|
});
|
|
});
|
|
|
|
it("rejects range-only :line tokens", () => {
|
|
expect(parseInlinePathToken(":12")).toBeNull();
|
|
expect(parseInlinePathToken(":12-20")).toBeNull();
|
|
});
|
|
});
|
|
|