Elffuss BraidHub

kikocis/continue public

main · 2.3 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 CN ASCII art 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("██████╗");
37 expect(result).toContain("(beta)");
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 CN ASCII art 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("██████╗");
50 expect(result).toContain("(beta)");
51 expect(result).not.toBe(CONTINUE_ASCII_ART);
52 });
53
54 it("should return full ASCII art when terminal is exactly at threshold", () => {
55 // Test the edge case at exactly 75 columns (our threshold)
56 process.stdout.columns = 75;
57
58 const result = getDisplayableAsciiArt();
59
60 expect(result).toBe(CONTINUE_ASCII_ART);
61 });
62
63 it("should default to full ASCII art when columns is undefined", () => {
64 // Set process.stdout.columns to undefined (should default to 80)
65 delete (process.stdout as any).columns;
66
67 const result = getDisplayableAsciiArt();
68
69 expect(result).toBe(CONTINUE_ASCII_ART);
70 });
71 });
72});