| 1 | import path from "path"; |
| 2 | |
| 3 | import { shouldChunk } from "./chunk"; |
| 4 | |
| 5 | describe("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 | |
| 31 | function generateString(length: number) { |
| 32 | return "a".repeat(length); |
| 33 | } |