UNPKG

matterbridge-roborock-vacuum-plugin

Version:
38 lines 2.12 kB
import { beforeEach, describe, expect, it, vi } from 'vitest'; import { CleanModeDisplayLabel } from '../../../../behaviors/roborock.vacuum/core/cleanModeConfig/index.js'; import { CleanModeSetting } from '../../../../behaviors/roborock.vacuum/core/CleanModeSetting.js'; import { CleanSequenceType, MopRoute, MopWaterFlow, VacuumSuctionPower, } from '../../../../behaviors/roborock.vacuum/enums/index.js'; import { CustomCleanModeHandler } from '../../../../behaviors/roborock.vacuum/handlers/customCleanModeHandler.js'; import { asPartial } from '../../../testUtils.js'; describe('CustomCleanModeHandler', () => { let handler; beforeEach(() => { handler = new CustomCleanModeHandler(); }); describe('canHandle', () => { it('should return true for MopAndVacuumEnergySaving', () => { expect(handler.canHandle(10, CleanModeDisplayLabel.VacuumAndMopEnergySaving)).toBe(true); }); it('should return false for other modes', () => { expect(handler.canHandle(5, CleanModeDisplayLabel.VacuumAndMopDefault)).toBe(false); }); }); describe('handle', () => { it('should call changeCleanMode with the provided setting', async () => { const mockRoborockService = { changeCleanMode: vi.fn() }; const mockLogger = { notice: vi.fn(), debug: vi.fn() }; const setting = new CleanModeSetting(VacuumSuctionPower.Custom, MopWaterFlow.Custom, 0, MopRoute.Custom, CleanSequenceType.Persist); const context = { roborockService: asPartial(mockRoborockService), logger: asPartial(mockLogger), enableCleanModeMapping: false, cleanModeSettings: undefined, cleanSettings: { 10: setting }, behaviorName: 'TestBehavior', }; await handler.handle('duid', 10, CleanModeDisplayLabel.VacuumAndMopEnergySaving, context); expect(mockRoborockService.changeCleanMode).toHaveBeenCalledWith('duid', setting); }); }); }); //# sourceMappingURL=customCleanModeHandler.test.js.map