mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-04-27 21:44:25 -07:00
Migrate core render util to use xterm.js as part of the rendering loop. (#19044)
This commit is contained in:
@@ -9,51 +9,73 @@ import { describe, it, expect } from 'vitest';
|
||||
import { QuotaDisplay } from './QuotaDisplay.js';
|
||||
|
||||
describe('QuotaDisplay', () => {
|
||||
it('should not render when remaining is undefined', () => {
|
||||
const { lastFrame } = render(
|
||||
it('should not render when remaining is undefined', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={undefined} limit={100} />,
|
||||
);
|
||||
expect(lastFrame()).toBe('');
|
||||
await waitUntilReady();
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should not render when limit is undefined', () => {
|
||||
const { lastFrame } = render(
|
||||
it('should not render when limit is undefined', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={100} limit={undefined} />,
|
||||
);
|
||||
expect(lastFrame()).toBe('');
|
||||
await waitUntilReady();
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should not render when limit is 0', () => {
|
||||
const { lastFrame } = render(<QuotaDisplay remaining={100} limit={0} />);
|
||||
expect(lastFrame()).toBe('');
|
||||
it('should not render when limit is 0', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={100} limit={0} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should not render when usage > 20%', () => {
|
||||
const { lastFrame } = render(<QuotaDisplay remaining={85} limit={100} />);
|
||||
expect(lastFrame()).toBe('');
|
||||
it('should not render when usage > 20%', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={85} limit={100} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame({ allowEmpty: true })).toBe('');
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should render yellow when usage < 20%', () => {
|
||||
const { lastFrame } = render(<QuotaDisplay remaining={15} limit={100} />);
|
||||
it('should render yellow when usage < 20%', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={15} limit={100} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should render red when usage < 5%', () => {
|
||||
const { lastFrame } = render(<QuotaDisplay remaining={4} limit={100} />);
|
||||
it('should render red when usage < 5%', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={4} limit={100} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should render with reset time when provided', () => {
|
||||
it('should render with reset time when provided', async () => {
|
||||
const resetTime = new Date(Date.now() + 3600000).toISOString(); // 1 hour from now
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={15} limit={100} resetTime={resetTime} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should NOT render reset time when terse is true', () => {
|
||||
it('should NOT render reset time when terse is true', async () => {
|
||||
const resetTime = new Date(Date.now() + 3600000).toISOString();
|
||||
const { lastFrame } = render(
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay
|
||||
remaining={15}
|
||||
limit={100}
|
||||
@@ -61,13 +83,17 @@ describe('QuotaDisplay', () => {
|
||||
terse={true}
|
||||
/>,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
|
||||
it('should render terse limit reached message', () => {
|
||||
const { lastFrame } = render(
|
||||
it('should render terse limit reached message', async () => {
|
||||
const { lastFrame, waitUntilReady, unmount } = render(
|
||||
<QuotaDisplay remaining={0} limit={100} terse={true} />,
|
||||
);
|
||||
await waitUntilReady();
|
||||
expect(lastFrame()).toMatchSnapshot();
|
||||
unmount();
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user