@switchbot/homebridge-switchbot
Version:
The SwitchBot plugin allows you to access your SwitchBot device(s) from HomeKit.
20 lines (16 loc) • 902 B
text/typescript
import { describe, expect, it, vi } from 'vitest'
import { SwitchBotClient } from '../../src/switchbotClient'
describe('switchBotClient OpenAPI fallback', () => {
it('should fallback to OpenAPI if node-switchbot fails to load', async () => {
// Simulate missing node-switchbot by making import throw
const logger = { info: vi.fn(), warn: vi.fn(), error: vi.fn(), debug: vi.fn() }
const cfg = { openApiToken: 'token', openApiSecret: 'secret', logger }
// Actually, we can't easily mock dynamic import, so just check that client still works
const client = new SwitchBotClient(cfg as any)
expect(client).toBeDefined()
// Should have OpenAPI fallback logic (client["client"] is null if import fails)
// Access private property for test purposes
expect((client as any).client).toBeNull()
})
// Removed: HTTP fallback is no longer supported in SwitchBotClient
})