From ba0cdf641d554d8228cabf9227eba5e6c3630230 Mon Sep 17 00:00:00 2001 From: John Knox Date: Fri, 22 Mar 2019 06:48:29 -0700 Subject: [PATCH] Fix error bar displaying Summary: The error was getting wiped accidentally if register device didn't have any error. In practice, meaning that the "flipper already running" message only flickered on the screen and then disappeared. Reviewed By: passy Differential Revision: D14576768 fbshipit-source-id: 1c7443f8f25ffa6a56f8d4994f3fef53bbb02c6d --- src/reducers/__tests__/connections.node.js | 27 ++++++++++++++++++++++ src/reducers/connections.js | 2 +- 2 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 src/reducers/__tests__/connections.node.js diff --git a/src/reducers/__tests__/connections.node.js b/src/reducers/__tests__/connections.node.js new file mode 100644 index 000000000..e2d47f05c --- /dev/null +++ b/src/reducers/__tests__/connections.node.js @@ -0,0 +1,27 @@ +/** + * Copyright 2018-present Facebook. + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * @format + */ + +import reducer from '../connections'; +import BaseDevice from '../../devices/BaseDevice'; +import type {State} from '../connections'; + +test('REGISTER_DEVICE doesnt remove error', () => { + const initialState: State = reducer(undefined, { + type: 'SERVER_ERROR', + payload: 'something went wrong', + }); + + // Precondition + expect(initialState.error).toEqual('something went wrong'); + + const endState = reducer(initialState, { + type: 'REGISTER_DEVICE', + payload: new BaseDevice('serial', 'physical', 'title'), + }); + + expect(endState.error).toEqual('something went wrong'); +}); diff --git a/src/reducers/connections.js b/src/reducers/connections.js index 0ed7e5be0..987f4a62e 100644 --- a/src/reducers/connections.js +++ b/src/reducers/connections.js @@ -172,7 +172,7 @@ export default function reducer( // select device if none was selected before selectedDevice, ...selection, - error, + error: error || state.error, }; } case 'UNREGISTER_DEVICES': {