/** * @license * Copyright 2025 Google LLC * SPDX-License-Identifier: Apache-2.0 */ import { render } from 'ink-testing-library'; import { describe, it, expect } from 'vitest'; import { StatRow, StatsColumn, DurationColumn, FormattedStats, } from './Stats.js'; import { Colors } from '../colors.js'; describe('', () => { it('renders a label and value', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); it('renders with a specific value color', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); }); describe('', () => { const mockStats: FormattedStats = { inputTokens: 100, outputTokens: 200, toolUseTokens: 50, thoughtsTokens: 25, cachedTokens: 10, totalTokens: 385, }; it('renders a stats column with children', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); it('renders a stats column with a specific width', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); it('renders a cumulative stats column with percentages', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); it('hides the tool use row when there are no tool use tokens', () => { const statsWithNoToolUse: FormattedStats = { ...mockStats, toolUseTokens: 0, }; const { lastFrame } = render( , ); expect(lastFrame()).not.toContain('Tool Use Tokens'); }); }); describe('', () => { it('renders a duration column', () => { const { lastFrame } = render( , ); expect(lastFrame()).toMatchSnapshot(); }); });