Download tests/import.test.ts from hongcoding/agentlens: direct link, hf CLI and curl.
- Browser
- Download file 1.37 kB
-
https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/import.test.ts
- Command line
-
hf download hf://datasets/hongcoding/agentlens/tests/import.test.ts
-
curl -L -o import.test.ts https://huggingface.co/datasets/hongcoding/agentlens/resolve/main/tests/import.test.ts
1.37 kB
| import { describe, it, expect } from "vitest"; | |
| import { mergeInstructions } from "../src/import/dsh-import.js"; | |
| import { readFileSync, writeFileSync, mkdtempSync } from "node:fs"; | |
| import { join } from "node:path"; | |
| import { tmpdir } from "node:os"; | |
| function tempFile(): string { | |
| const dir = mkdtempSync(join(tmpdir(), "agentlens-import-")); | |
| return join(dir, "AGENTS.md"); | |
| } | |
| describe("mergeInstructions", () => { | |
| it("appends the import section and keeps existing content", () => { | |
| const file = tempFile(); | |
| writeFileSync(file, "# Existing rules\n\n- Keep this\n", "utf8"); | |
| mergeInstructions(file, "/data/dsh"); | |
| const out = readFileSync(file, "utf8"); | |
| expect(out).toContain("- Keep this"); | |
| expect(out).toContain("agentlens-import:start"); | |
| expect(out).toContain("/data/dsh/persona.md"); | |
| }); | |
| it("is idempotent across repeated runs", () => { | |
| const file = tempFile(); | |
| writeFileSync(file, "# Existing\n", "utf8"); | |
| mergeInstructions(file, "/data/a"); | |
| mergeInstructions(file, "/data/a"); | |
| mergeInstructions(file, "/data/b"); | |
| const out = readFileSync(file, "utf8"); | |
| // Exactly one section, and it reflects the latest data dir. | |
| expect((out.match(/agentlens-import:start/g) || []).length).toBe(1); | |
| expect(out).toContain("/data/b/persona.md"); | |
| expect(out).not.toContain("/data/a/persona.md"); | |
| }); | |
| }); | |