|
| 1 | +/** |
| 2 | + * @license |
| 3 | + * Copyright 2025 Google LLC |
| 4 | + * SPDX-License-Identifier: Apache-2.0 |
| 5 | + */ |
| 6 | + |
| 7 | +import { describe, it, expect, afterEach, vi } from 'vitest'; |
| 8 | +import { renderWithProviders } from '../../test-utils/render.js'; |
| 9 | +import { ShortcutsHelp } from './ShortcutsHelp.js'; |
| 10 | + |
| 11 | +describe('ShortcutsHelp', () => { |
| 12 | + const originalPlatform = process.platform; |
| 13 | + |
| 14 | + afterEach(() => { |
| 15 | + Object.defineProperty(process, 'platform', { |
| 16 | + value: originalPlatform, |
| 17 | + }); |
| 18 | + vi.restoreAllMocks(); |
| 19 | + }); |
| 20 | + |
| 21 | + const testCases = [ |
| 22 | + { name: 'wide', width: 100 }, |
| 23 | + { name: 'narrow', width: 40 }, |
| 24 | + ]; |
| 25 | + |
| 26 | + const platforms = [ |
| 27 | + { name: 'mac', value: 'darwin' }, |
| 28 | + { name: 'linux', value: 'linux' }, |
| 29 | + ] as const; |
| 30 | + |
| 31 | + it.each( |
| 32 | + platforms.flatMap((platform) => |
| 33 | + testCases.map((testCase) => ({ ...testCase, platform })), |
| 34 | + ), |
| 35 | + )( |
| 36 | + 'renders correctly in $name mode on $platform.name', |
| 37 | + ({ width, platform }) => { |
| 38 | + Object.defineProperty(process, 'platform', { |
| 39 | + value: platform.value, |
| 40 | + }); |
| 41 | + |
| 42 | + const { lastFrame } = renderWithProviders(<ShortcutsHelp />, { |
| 43 | + width, |
| 44 | + }); |
| 45 | + expect(lastFrame()).toContain('shell mode'); |
| 46 | + expect(lastFrame()).toMatchSnapshot(); |
| 47 | + }, |
| 48 | + ); |
| 49 | +}); |
0 commit comments