File size: 1,228 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
/**
 * @license
 * Copyright 2025 Google LLC
 * SPDX-License-Identifier: Apache-2.0
 */

import { describe, it, expect, afterEach, vi } from 'vitest';
import { renderWithProviders } from '../../../test-utils/render.js';
import { SectionHeader } from './SectionHeader.js';

describe('<SectionHeader />', () => {
  afterEach(() => {
    vi.restoreAllMocks();
  });

  it.each([
    {
      description: 'renders correctly with a standard title',
      title: 'My Header',
      width: 40,
    },
    {
      description:
        'renders correctly when title is truncated but still shows dashes',
      title: 'Very Long Header Title That Will Truncate',
      width: 20,
    },
    {
      description: 'renders correctly in a narrow container',
      title: 'Narrow Container',
      width: 25,
    },
    {
      description: 'renders correctly with a subtitle',
      title: 'Shortcuts',
      subtitle: ' See /help for more',
      width: 40,
    },
  ])('$description', async ({ title, subtitle, width }) => {
    const { lastFrame, unmount } = await renderWithProviders(
      <SectionHeader title={title} subtitle={subtitle} />,
      { width },
    );

    expect(lastFrame()).toMatchSnapshot();
    unmount();
  });
});