Elffuss BraidHub

kikocis/continue public

627d7d0d1f85 · 1.1 KiBRawPermalink
1import path from "path";
2
3import { shouldChunk } from "./chunk";
4
5describe("shouldChunk", () => {
6 test("should chunk a typescript file", () => {
7 const filePath = path.join("directory", "file.ts");
8 const fileContent = generateString(10000);
9 expect(shouldChunk(filePath, fileContent)).toBe(true);
10 });
11
12 test("should not chunk a large typescript file", () => {
13 const filePath = path.join("directory", "file.ts");
14 const fileContent = generateString(1500000);
15 expect(shouldChunk(filePath, fileContent)).toBe(false);
16 });
17
18 test("should not chunk an empty file", () => {
19 const filePath = path.join("directory", "file.ts");
20 const fileContent = generateString(0);
21 expect(shouldChunk(filePath, fileContent)).toBe(false);
22 });
23
24 test("should not chunk a file without extension", () => {
25 const filePath = path.join("directory", "with.dot", "filename");
26 const fileContent = generateString(10000);
27 expect(shouldChunk(filePath, fileContent)).toBe(false);
28 });
29});
30
31function generateString(length: number) {
32 return "a".repeat(length);
33}