forked from anomalyco/opencode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathskeleton-python.test.ts
More file actions
27 lines (22 loc) · 898 Bytes
/
skeleton-python.test.ts
File metadata and controls
27 lines (22 loc) · 898 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
import { describe, it, expect } from "vitest"
import { resolve } from "node:path"
import { skeletonizeFile } from "../packages/repo-index/src/skeleton"
describe("skeletonize python", () => {
const root = resolve("fixtures/py-mini")
const path = resolve(root, "pkg/mathy.py")
const sk = skeletonizeFile(root, path)
it("emits a readable skeleton", () => {
expect(sk.text).toContain("# File: pkg/mathy.py")
expect(sk.text).toContain("def add(a, b):")
expect(sk.text).toContain("class Accumulator:")
})
it("includes docstrings when present", () => {
expect(sk.text).toMatch(/"""Add two numbers.+"""/s)
})
it("adds elision markers with sha1", () => {
expect(sk.elisions.length).toBeGreaterThan(0)
const e = sk.elisions[0]
expect(e.sha1).toMatch(/^[0-9a-f]{40}$/)
expect(sk.text).toMatch(/⟪ELIDED L\d+-\d+; \d+ lines; sha1=[0-9a-f]{40}⟫/)
})
})