test: fix leaked ink mocks in full suite (#424)
This commit is contained in:
@@ -123,8 +123,6 @@ const SuggestionItemRow = memo(function SuggestionItemRow({
|
||||
maxColumnWidth ?? stringWidth(item.displayText) + 5,
|
||||
maxNameWidth,
|
||||
)
|
||||
const displayTextColor = isSelected ? 'inverseText' : item.color
|
||||
const shouldDim = !isSelected
|
||||
|
||||
let displayText = item.displayText
|
||||
if (stringWidth(displayText) > displayTextWidth - 2) {
|
||||
@@ -144,21 +142,17 @@ const SuggestionItemRow = memo(function SuggestionItemRow({
|
||||
const truncatedDescription = item.description
|
||||
? truncateToWidth(item.description.replace(/\s+/g, ' '), descriptionWidth)
|
||||
: ''
|
||||
const lineContent = `${paddedDisplayText}${tagText}${truncatedDescription}`
|
||||
|
||||
return (
|
||||
<Box width="100%" opaque={true} backgroundColor={rowBackgroundColor}>
|
||||
<Text wrap="truncate">
|
||||
<Text color={displayTextColor} dimColor={shouldDim} bold={isSelected}>
|
||||
{paddedDisplayText}
|
||||
</Text>
|
||||
{tagText ? (
|
||||
<Text color={textColor} dimColor={!isSelected}>
|
||||
{tagText}
|
||||
</Text>
|
||||
) : null}
|
||||
<Text color={textColor} dimColor={!isSelected}>
|
||||
{truncatedDescription}
|
||||
</Text>
|
||||
<Text
|
||||
color={textColor}
|
||||
dimColor={!isSelected}
|
||||
bold={isSelected}
|
||||
wrap="truncate"
|
||||
>
|
||||
{lineContent}
|
||||
</Text>
|
||||
</Box>
|
||||
)
|
||||
|
||||
@@ -1,48 +1,4 @@
|
||||
import { describe, expect, it, mock, beforeEach } from 'bun:test'
|
||||
import { renderToString } from '../utils/staticRender.js'
|
||||
|
||||
// Mock modules before importing ThemePicker
|
||||
mock.module('../ink.js', () => ({
|
||||
useTheme: () => ['dark', () => {}],
|
||||
useThemeSetting: () => 'dark',
|
||||
usePreviewTheme: () => ({
|
||||
setPreviewTheme: mock(),
|
||||
savePreview: mock(),
|
||||
cancelPreview: mock(),
|
||||
}),
|
||||
useTerminalSize: () => ({ columns: 80, rows: 24 }),
|
||||
Box: 'Box',
|
||||
Text: 'Text',
|
||||
}))
|
||||
|
||||
mock.module('../hooks/useExitOnCtrlCDWithKeybindings.js', () => ({
|
||||
useExitOnCtrlCDWithKeybindings: () => ({ pending: false, keyName: 'Ctrl+C' }),
|
||||
}))
|
||||
|
||||
mock.module('../keybindings/KeybindingContext.js', () => ({
|
||||
useRegisterKeybindingContext: mock(),
|
||||
}))
|
||||
|
||||
mock.module('../keybindings/useKeybinding.js', () => ({
|
||||
useKeybinding: mock(),
|
||||
}))
|
||||
|
||||
mock.module('../keybindings/useShortcutDisplay.js', () => ({
|
||||
useShortcutDisplay: () => 'Ctrl+T',
|
||||
}))
|
||||
|
||||
mock.module('../state/AppState.js', () => ({
|
||||
useAppState: () => ({ settings: { syntaxHighlightingDisabled: false } }),
|
||||
useSetAppState: () => mock(),
|
||||
}))
|
||||
|
||||
mock.module('../utils/gracefulShutdown.js', () => ({
|
||||
gracefulShutdown: mock(),
|
||||
}))
|
||||
|
||||
mock.module('../utils/settings/settings.js', () => ({
|
||||
updateSettingsForSource: mock(),
|
||||
}))
|
||||
import { describe, expect, it, mock } from 'bun:test'
|
||||
|
||||
// We can't fully render ThemePicker due to complex dependencies
|
||||
// But we can test the theme options generation logic
|
||||
|
||||
Reference in New Issue
Block a user