diff --git a/discovery-client/src/store/__tests__/hostsByIpReducer.test.ts b/discovery-client/src/store/__tests__/hostsByIpReducer.test.ts index 221e2182d00..5ffef141e77 100644 --- a/discovery-client/src/store/__tests__/hostsByIpReducer.test.ts +++ b/discovery-client/src/store/__tests__/hostsByIpReducer.test.ts @@ -513,6 +513,25 @@ describe('hostsByIp reducer', () => { }) it('should handle "client:REMOVE_ROBOT"', () => { + const action = Actions.removeRobot('opentrons-dev') + const initialState = { + '127.0.0.1': { + ip: '127.0.0.1', + port: 31950, + seen: false, + healthStatus: null, + serverHealthStatus: null, + healthError: null, + serverHealthError: null, + robotName: 'opentrons-dev', + }, + } + const nextState = hostsByIpReducer(initialState, action) + + expect(nextState).toEqual({}) + }) + + it('should handle "client:REMOVE_ROBOT" with multiple matching hosts', () => { const action = Actions.removeRobot('opentrons-dev') const initialState = { '127.0.0.1': { diff --git a/discovery-client/src/store/reducer.ts b/discovery-client/src/store/reducer.ts index 687faea5564..ec207f442d6 100644 --- a/discovery-client/src/store/reducer.ts +++ b/discovery-client/src/store/reducer.ts @@ -141,7 +141,7 @@ export const hostsByIpReducer = ( return robotName === targetRobotName }) - return removals.length > 1 ? omit(state, removals) : state + return removals.length > 0 ? omit(state, removals) : state } case Actions.SERVICE_FOUND: {