diff --git a/tests/unit/services/cwmp/executing_commands.spec.ts b/tests/unit/services/cwmp/executing_commands.spec.ts index 4967bc9..e4e18c3 100644 --- a/tests/unit/services/cwmp/executing_commands.spec.ts +++ b/tests/unit/services/cwmp/executing_commands.spec.ts @@ -194,8 +194,16 @@ describe('ExecutingCommandsState — direct testing', () => { const cmd = { _id: 'c8', action: 'INVALID_TYPE', parameters: {}, status: CommandStatus.PENDING, mode: ModeType.I, priority: 1 } setupCommandMock([cmd]) - expect(vi.mocked(logger.error)).toHaveBeenCalled() - expect(vi.mocked(CommandModel.updateCommand)).toHaveBeenCalledWith('c8', expect.objectContaining({ status: CommandStatus.FAILED })) + const device = makeDevice() + const context = makeContext(device) + const state = new ExecutingCommandsState(true) + + await state.handle(context) + + expect(vi.mocked(CommandModel.updateCommand)).toHaveBeenCalledWith( + 'c8', + expect.objectContaining({ status: CommandStatus.FAILED }) + ) }) it('marks command COMPLETED on success response and does SPV optimistic update', async () => { @@ -236,6 +244,8 @@ describe('ExecutingCommandsState — direct testing', () => { // Second handle: receives fault context.message = { success: false, data: { FaultCode: 9001 } } + await state.handle(context) + expect(vi.mocked(CommandModel.updateCommand)).toHaveBeenCalledWith('c10', expect.objectContaining({ status: CommandStatus.FAILED })) }) })