From 0c7b03cad321a84ac8832b1423543befc2efde0c Mon Sep 17 00:00:00 2001 From: Pascal Hartig Date: Fri, 6 Dec 2019 06:30:07 -0800 Subject: [PATCH] Add tests for settings reducer Summary: yiss_tests Reviewed By: jknoxville Differential Revision: D18851134 fbshipit-source-id: 53ffb9b516773df19c258e7d819962e3cd523751 --- src/reducers/__tests__/settings.node.tsx | 36 ++++++++++++++++++++++++ 1 file changed, 36 insertions(+) create mode 100644 src/reducers/__tests__/settings.node.tsx diff --git a/src/reducers/__tests__/settings.node.tsx b/src/reducers/__tests__/settings.node.tsx new file mode 100644 index 000000000..02c20c2c6 --- /dev/null +++ b/src/reducers/__tests__/settings.node.tsx @@ -0,0 +1,36 @@ +/** + * Copyright (c) Facebook, Inc. and its affiliates. + * + * This source code is licensed under the MIT license found in the + * LICENSE file in the root directory of this source tree. + * + * @format + */ + +import {default as reducer, updateSettings, Tristate} from '../settings'; + +test('init', () => { + const res = reducer(undefined, {type: 'INIT'}); + expect(res.enableAndroid).toBeTruthy(); +}); + +test('updateSettings', () => { + const initialSettings = reducer(undefined, {type: 'INIT'}); + const updatedSettings = Object.assign(initialSettings, { + enableAndroid: false, + enablePrefetching: Tristate.True, + jsApps: { + webAppLauncher: { + height: 900, + }, + }, + }); + const res = reducer(initialSettings, updateSettings(updatedSettings)); + + expect(res.enableAndroid).toBeFalsy(); + expect(res.enablePrefetching).toEqual(Tristate.True); + expect(res.jsApps.webAppLauncher.height).toEqual(900); + expect(res.jsApps.webAppLauncher.width).toEqual( + initialSettings.jsApps.webAppLauncher.width, + ); +});