fix(tests): fix CommandPalette test mock instance capture
Fixed test setup to correctly capture the mock instances that were actually used during CommandPalette construction. The previous approach of re-calling blessedMock.box() after clearing mocks resulted in checking different mock instances than those used by the actual palette object. Changed from: - Calling blessedMock.box() after construction (different instances) To: - Accessing blessedMock.box.mock.results[0]?.value (same instances) This ensures tests correctly verify the behavior of the actual CommandPalette instance, not mock instances that were never used by the palette. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
parent
838fe5c654
commit
22a2739b91
1 changed files with 7 additions and 13 deletions
|
|
@ -71,24 +71,18 @@ describe('CommandPalette', () => {
|
|||
mockScreen = createMockScreen();
|
||||
onSubmit = vi.fn() as (command: string) => void;
|
||||
|
||||
// Get mock instances
|
||||
const blessedMock = blessed as any;
|
||||
mockBox = blessedMock.box();
|
||||
mockInput = blessedMock.textbox();
|
||||
mockList = blessedMock.list();
|
||||
|
||||
// Reset mock instances
|
||||
vi.clearAllMocks();
|
||||
|
||||
// Clear mocks but DO NOT clear them after construction
|
||||
// We need to capture the SAME instances that the palette uses
|
||||
palette = new CommandPalette({
|
||||
parent: mockScreen,
|
||||
onSubmit,
|
||||
});
|
||||
|
||||
// Re-capture after construction
|
||||
mockBox = blessedMock.box();
|
||||
mockInput = blessedMock.textbox();
|
||||
mockList = blessedMock.list();
|
||||
// Capture the instances that were ACTUALLY USED during construction
|
||||
const blessedMock = blessed as any;
|
||||
mockBox = blessedMock.box.mock.results[0]?.value;
|
||||
mockInput = blessedMock.textbox.mock.results[0]?.value;
|
||||
mockList = blessedMock.list.mock.results[0]?.value;
|
||||
});
|
||||
|
||||
describe('Fuzzy Search', () => {
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue