From 4f2974dbfe36638915f1b08448d2563c64f88644 Mon Sep 17 00:00:00 2001 From: Gal Zahavi <38544478+galz10@users.noreply.github.com> Date: Thu, 7 Aug 2025 15:55:53 -0700 Subject: feat(ui): Improve UI layout adaptation for narrow terminals (#5651) Co-authored-by: Jacob Richman --- packages/cli/src/ui/components/Header.test.tsx | 44 ++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 packages/cli/src/ui/components/Header.test.tsx (limited to 'packages/cli/src/ui/components/Header.test.tsx') diff --git a/packages/cli/src/ui/components/Header.test.tsx b/packages/cli/src/ui/components/Header.test.tsx new file mode 100644 index 00000000..95ed3f07 --- /dev/null +++ b/packages/cli/src/ui/components/Header.test.tsx @@ -0,0 +1,44 @@ +/** + * @license + * Copyright 2025 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ + +import { render } from 'ink-testing-library'; +import { describe, it, expect, vi, beforeEach } from 'vitest'; +import { Header } from './Header.js'; +import * as useTerminalSize from '../hooks/useTerminalSize.js'; +import { longAsciiLogo } from './AsciiArt.js'; + +vi.mock('../hooks/useTerminalSize.js'); + +describe('
', () => { + beforeEach(() => {}); + + it('renders the long logo on a wide terminal', () => { + vi.spyOn(useTerminalSize, 'useTerminalSize').mockReturnValue({ + columns: 120, + rows: 20, + }); + const { lastFrame } = render(
); + expect(lastFrame()).toContain(longAsciiLogo); + }); + + it('renders custom ASCII art when provided', () => { + const customArt = 'CUSTOM ART'; + const { lastFrame } = render( +
, + ); + expect(lastFrame()).toContain(customArt); + }); + + it('displays the version number when nightly is true', () => { + const { lastFrame } = render(
); + expect(lastFrame()).toContain('v1.0.0'); + }); + + it('does not display the version number when nightly is false', () => { + const { lastFrame } = render(
); + expect(lastFrame()).not.toContain('v1.0.0'); + }); +}); -- cgit v1.2.3