File size: 1,740 Bytes
52efc7b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import { describe, it, expect } from 'vitest';
import { ToolsList } from './ToolsList.js';
import { type ToolDefinition } from '../../types.js';
import { renderWithProviders } from '../../../test-utils/render.js';

const mockTools: ToolDefinition[] = [
  {
    name: 'test-tool-one',
    displayName: 'Test Tool One',
    description: 'This is the first test tool.',
  },
  {
    name: 'test-tool-two',
    displayName: 'Test Tool Two',
    description: `This is the second test tool.
  1. Tool descriptions support markdown formatting.
  2. **note** use this tool wisely and be sure to consider how this tool interacts with word wrap.
  3. **important** this tool is awesome.`,
  },
  {
    name: 'test-tool-three',
    displayName: 'Test Tool Three',
    description: 'This is the third test tool.',
  },
];

describe('<ToolsList />', () => {
  it('renders correctly with descriptions', async () => {
    const { lastFrame } = await renderWithProviders(
      <ToolsList
        tools={mockTools}
        showDescriptions={true}
        terminalWidth={40}
      />,
    );
    expect(lastFrame()).toMatchSnapshot();
  });

  it('renders correctly without descriptions', async () => {
    const { lastFrame } = await renderWithProviders(
      <ToolsList
        tools={mockTools}
        showDescriptions={false}
        terminalWidth={40}
      />,
    );
    expect(lastFrame()).toMatchSnapshot();
  });

  it('renders correctly with no tools', async () => {
    const { lastFrame } = await renderWithProviders(
      <ToolsList tools={[]} showDescriptions={true} terminalWidth={40} />,
    );
    expect(lastFrame()).toMatchSnapshot();
  });
});