From 6909a4a3158fa2136d09adc2e40bd0c4e1ddf838 Mon Sep 17 00:00:00 2001 From: John Knox Date: Thu, 10 Oct 2019 09:21:35 -0700 Subject: [PATCH] Add snapshot tests for settings Summary: Take a snapshot with each field adjusted to prevent accidental changes. Reviewed By: priteshrnandgaonkar Differential Revision: D17832181 fbshipit-source-id: 016f99ec032036993a40fea310c6fd9887da6c38 --- src/chrome/__tests__/SettingsSheet.node.tsx | 73 +++ .../__snapshots__/SettingsSheet.node.tsx.snap | 540 ++++++++++++++++++ 2 files changed, 613 insertions(+) create mode 100644 src/chrome/__tests__/SettingsSheet.node.tsx create mode 100644 src/chrome/__tests__/__snapshots__/SettingsSheet.node.tsx.snap diff --git a/src/chrome/__tests__/SettingsSheet.node.tsx b/src/chrome/__tests__/SettingsSheet.node.tsx new file mode 100644 index 000000000..d30959072 --- /dev/null +++ b/src/chrome/__tests__/SettingsSheet.node.tsx @@ -0,0 +1,73 @@ +/** + * 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 SettingsSheet from '../SettingsSheet'; +import React from 'react'; +import renderer from 'react-test-renderer'; +import configureStore from 'redux-mock-store'; +import {Provider} from 'react-redux'; + +function getStore({ + iosEnabled, + androidEnabled, + androidHome, +}: { + iosEnabled?: boolean; + androidEnabled?: boolean; + androidHome?: string; +}) { + return configureStore([])({ + application: { + sessionId: 'mysession', + xcodeCommandLineToolsDetected: iosEnabled, + }, + settingsState: { + enableAndroid: androidEnabled, + androidHome: androidHome, + }, + }); +} + +test('SettingsSheet snapshot with nothing enabled', () => { + const component = ( + + {}} /> + + ); + + expect(renderer.create(component).toJSON()).toMatchSnapshot(); +}); + +test('SettingsSheet snapshot with iOS enabled', () => { + const component = ( + + {}} /> + + ); + + expect(renderer.create(component).toJSON()).toMatchSnapshot(); +}); + +test('SettingsSheet snapshot with android enabled', () => { + const component = ( + + {}} /> + + ); + + expect(renderer.create(component).toJSON()).toMatchSnapshot(); +}); + +test('SettingsSheet snapshot with android home set', () => { + const component = ( + + {}} /> + + ); + + expect(renderer.create(component).toJSON()).toMatchSnapshot(); +}); diff --git a/src/chrome/__tests__/__snapshots__/SettingsSheet.node.tsx.snap b/src/chrome/__tests__/__snapshots__/SettingsSheet.node.tsx.snap new file mode 100644 index 000000000..dad611a79 --- /dev/null +++ b/src/chrome/__tests__/__snapshots__/SettingsSheet.node.tsx.snap @@ -0,0 +1,540 @@ +// Jest Snapshot v1, https://goo.gl/fbAQLP + +exports[`SettingsSheet snapshot with android enabled 1`] = ` +
+ + Settings + +
+
+
+
+ + Android Developer + +
+
+
+
+ + Android SDK Location + + +
+ dots-3-circle +
+
+
+
+
+
+
+
+ + iOS Developer + +
+
+
+
+ +
+ + Use xcode-select to enable or switch between xcode versions + +
+
+
+
+
+
+
+
+
+ Cancel +
+
+ Apply and Restart +
+
+
+`; + +exports[`SettingsSheet snapshot with android home set 1`] = ` +
+ + Settings + +
+
+
+
+ + Android Developer + +
+
+
+
+ + Android SDK Location + + +
+ dots-3-circle +
+
+
+
+
+
+
+
+
+ + iOS Developer + +
+
+
+
+ +
+ + Use xcode-select to enable or switch between xcode versions + +
+
+
+
+
+
+
+
+
+ Cancel +
+
+ Apply and Restart +
+
+
+`; + +exports[`SettingsSheet snapshot with iOS enabled 1`] = ` +
+ + Settings + +
+
+
+
+ + Android Developer + +
+
+
+
+ + Android SDK Location + + +
+ dots-3-circle +
+
+
+
+
+
+
+
+
+ + iOS Developer + +
+
+
+
+ +
+ + Use xcode-select to enable or switch between xcode versions + +
+
+
+
+
+
+
+
+ Cancel +
+
+ Apply and Restart +
+
+
+`; + +exports[`SettingsSheet snapshot with nothing enabled 1`] = ` +
+ + Settings + +
+
+
+
+ + Android Developer + +
+
+
+
+ + Android SDK Location + + +
+ dots-3-circle +
+
+
+
+
+
+
+
+
+ + iOS Developer + +
+
+
+
+ +
+ + Use xcode-select to enable or switch between xcode versions + +
+
+
+
+
+
+
+
+
+ Cancel +
+
+ Apply and Restart +
+
+
+`;