diff --git a/src/hub/reducers.test.ts b/src/hub/reducers.test.ts index 8c403ae9..4b1e2dc0 100644 --- a/src/hub/reducers.test.ts +++ b/src/hub/reducers.test.ts @@ -4,7 +4,7 @@ import { Action } from '../actions'; import { statusReportEvent } from '../ble-pybricks-service/actions'; import { Status, statusToFlag } from '../ble-pybricks-service/protocol'; -import { didDisconnect } from '../ble/actions'; +import { didConnect, didDisconnect } from '../ble/actions'; import { didFailToFinishDownload, didFinishDownload, @@ -25,6 +25,13 @@ test('initial state', () => { }); describe('runtime', () => { + test('', () => { + expect( + reducers({ runtime: HubRuntimeState.Disconnected } as State, didConnect()) + .runtime, + ).toBe(HubRuntimeState.Unknown); + }); + test.each(Object.values(HubRuntimeState))('didDisconnect', (startingState) => { // all states are overridden by disconnect expect( diff --git a/src/hub/reducers.ts b/src/hub/reducers.ts index 5f87654b..934e3d03 100644 --- a/src/hub/reducers.ts +++ b/src/hub/reducers.ts @@ -43,6 +43,8 @@ const runtime: Reducer = ( action, ) => { switch (action.type) { + case BleDeviceActionType.DidConnect: + return HubRuntimeState.Unknown; case BleDeviceActionType.DidDisconnect: return HubRuntimeState.Disconnected; case HubActionType.DidStartDownload: