Elffuss BraidHub

kikocis/continue public

5fda066adb4e · 2.2 KiBRawPermalink
1import { afterEach, beforeEach, describe, expect, it } from "vitest";
2
3import { CONTINUE_ASCII_ART, getDisplayableAsciiArt } from "./asciiArt.js";
4
5describe("asciiArt", () => {
6 let originalColumns: number | undefined;
7
8 beforeEach(() => {
9 originalColumns = process.stdout.columns;
10 });
11
12 afterEach(() => {
13 if (originalColumns === undefined) {
14 delete (process.stdout as any).columns;
15 } else {
16 process.stdout.columns = originalColumns;
17 }
18 });
19
20 describe("getDisplayableAsciiArt", () => {
21 it("should return full ASCII art when terminal is wide enough", () => {
22 // Set process.stdout.columns to simulate wide terminal
23 process.stdout.columns = 80;
24
25 const result = getDisplayableAsciiArt();
26
27 expect(result).toBe(CONTINUE_ASCII_ART);
28 });
29
30 it("should return simple text version when terminal is too narrow", () => {
31 // Set process.stdout.columns to simulate narrow terminal
32 process.stdout.columns = 60;
33
34 const result = getDisplayableAsciiArt();
35
36 expect(result).toContain("CONTINUE");
37 // expect(result).toContain("v0.0.0-dev");
38 expect(result).not.toBe(CONTINUE_ASCII_ART);
39 // Should be much shorter than the full ASCII art
40 expect(result.length).toBeLessThan(CONTINUE_ASCII_ART.length / 2);
41 });
42
43 it("should return simple text version when terminal is below threshold", () => {
44 // Test the edge case at exactly 74 columns (below our threshold of 75)
45 process.stdout.columns = 74;
46
47 const result = getDisplayableAsciiArt();
48
49 expect(result).toContain("CONTINUE");
50 expect(result).not.toBe(CONTINUE_ASCII_ART);
51 });
52
53 it("should return full ASCII art when terminal is exactly at threshold", () => {
54 // Test the edge case at exactly 75 columns (our threshold)
55 process.stdout.columns = 75;
56
57 const result = getDisplayableAsciiArt();
58
59 expect(result).toBe(CONTINUE_ASCII_ART);
60 });
61
62 it("should default to full ASCII art when columns is undefined", () => {
63 // Set process.stdout.columns to undefined (should default to 80)
64 delete (process.stdout as any).columns;
65
66 const result = getDisplayableAsciiArt();
67
68 expect(result).toBe(CONTINUE_ASCII_ART);
69 });
70 });
71});