Add tests for settings reducer

Summary: yiss_tests

Reviewed By: jknoxville

Differential Revision: D18851134

fbshipit-source-id: 53ffb9b516773df19c258e7d819962e3cd523751
This commit is contained in:
Pascal Hartig
2019-12-06 06:30:07 -08:00
committed by Facebook Github Bot
parent 425d4b9024
commit 0c7b03cad3

View File

@@ -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,
);
});