UNPKG

matterbridge-roborock-vacuum-plugin

Version:
48 lines 2.04 kB
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { RoborockService } from '../../../services/roborockService.js'; import { asPartial } from '../../testUtils.js'; describe('RoborockService (unit)', () => { let logger; let container; let authService; beforeEach(() => { logger = { debug: vi.fn(), notice: vi.fn(), error: vi.fn() }; authService = { authenticate: vi.fn(), }; // Minimal container mock used by RoborockService when injected container = { getAuthenticationCoordinator: () => authService, getDeviceManagementService: () => ({}), getAreaManagementService: () => ({ getSelectedAreas: () => [], getSupportedAreas: () => [] }), getMessageRoutingService: () => ({}), getPollingService: () => ({ setDeviceNotify: vi.fn(), activateDeviceNotifyOverLocal: vi.fn(), activateDeviceNotifyOverMQTT: vi.fn(), stopPolling: vi.fn(), }), getConnectionService: () => ({ initializeMessageClient: vi.fn(), initializeMessageClientForLocal: vi.fn().mockResolvedValue(false), setDeviceNotify: vi.fn(), }), setUserData: vi.fn(), getIotApi: () => undefined, }; }); it('getCustomAPI throws when IoT API not initialized', async () => { const svc = new RoborockService({ authenticateApiFactory: () => asPartial({}), iotApiFactory: () => asPartial({}), refreshInterval: 10, baseUrl: 'https://api.roborock.com', persist: asPartial({}), configManager: asPartial({}), container: container, toastMessage: vi.fn(), }, asPartial(logger), asPartial({})); await expect(svc.getCustomAPI('/some')).rejects.toThrow(/IoT API not initialized/); }); }); //# sourceMappingURL=roborockService.custom.test.js.map