Skip to content

Commit 4828980

Browse files
Johnny Dunnclaude
authored andcommitted
fix(tests): correct assertion in deviceManager re-init test
The test was asserting exec is called exactly once, but DeviceManager may call exec multiple times during initialization (table + index). Changed to assert that re-initializing doesn't add more exec calls. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
1 parent 65b75ca commit 4828980

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

tests/deviceManager.spec.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,15 @@ describe('DeviceManager', () => {
8888
it('should not re-initialize if already initialized', async () => {
8989
manager = new DeviceManager({ adapter });
9090
await manager.initialize();
91+
92+
// Track how many exec calls after first init
93+
const execCallsAfterFirstInit = (adapter.exec as ReturnType<typeof vi.fn>).mock.calls.length;
94+
9195
await manager.initialize();
9296

93-
// exec should only be called once for table creation
94-
const execCalls = (adapter.exec as ReturnType<typeof vi.fn>).mock.calls;
95-
expect(execCalls.length).toBe(1);
97+
// Re-initializing should not add more exec calls
98+
const execCallsAfterSecondInit = (adapter.exec as ReturnType<typeof vi.fn>).mock.calls.length;
99+
expect(execCallsAfterSecondInit).toBe(execCallsAfterFirstInit);
96100
});
97101

98102
it('should emit deviceRegistered event', async () => {

0 commit comments

Comments
 (0)