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,
|
maxColumnWidth ?? stringWidth(item.displayText) + 5,
|
||||||
maxNameWidth,
|
maxNameWidth,
|
||||||
)
|
)
|
||||||
const displayTextColor = isSelected ? 'inverseText' : item.color
|
|
||||||
const shouldDim = !isSelected
|
|
||||||
|
|
||||||
let displayText = item.displayText
|
let displayText = item.displayText
|
||||||
if (stringWidth(displayText) > displayTextWidth - 2) {
|
if (stringWidth(displayText) > displayTextWidth - 2) {
|
||||||
@@ -144,21 +142,17 @@ const SuggestionItemRow = memo(function SuggestionItemRow({
|
|||||||
const truncatedDescription = item.description
|
const truncatedDescription = item.description
|
||||||
? truncateToWidth(item.description.replace(/\s+/g, ' '), descriptionWidth)
|
? truncateToWidth(item.description.replace(/\s+/g, ' '), descriptionWidth)
|
||||||
: ''
|
: ''
|
||||||
|
const lineContent = `${paddedDisplayText}${tagText}${truncatedDescription}`
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<Box width="100%" opaque={true} backgroundColor={rowBackgroundColor}>
|
<Box width="100%" opaque={true} backgroundColor={rowBackgroundColor}>
|
||||||
<Text wrap="truncate">
|
<Text
|
||||||
<Text color={displayTextColor} dimColor={shouldDim} bold={isSelected}>
|
color={textColor}
|
||||||
{paddedDisplayText}
|
dimColor={!isSelected}
|
||||||
</Text>
|
bold={isSelected}
|
||||||
{tagText ? (
|
wrap="truncate"
|
||||||
<Text color={textColor} dimColor={!isSelected}>
|
>
|
||||||
{tagText}
|
{lineContent}
|
||||||
</Text>
|
|
||||||
) : null}
|
|
||||||
<Text color={textColor} dimColor={!isSelected}>
|
|
||||||
{truncatedDescription}
|
|
||||||
</Text>
|
|
||||||
</Text>
|
</Text>
|
||||||
</Box>
|
</Box>
|
||||||
)
|
)
|
||||||
|
|||||||
@@ -1,48 +1,4 @@
|
|||||||
import { describe, expect, it, mock, beforeEach } from 'bun:test'
|
import { describe, expect, it, mock } 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(),
|
|
||||||
}))
|
|
||||||
|
|
||||||
// We can't fully render ThemePicker due to complex dependencies
|
// We can't fully render ThemePicker due to complex dependencies
|
||||||
// But we can test the theme options generation logic
|
// But we can test the theme options generation logic
|
||||||
|
|||||||
Reference in New Issue
Block a user