diff --git a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js
index 8be9b345bfa..ec97e8255c4 100644
--- a/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js
+++ b/Libraries/Components/ActivityIndicator/__tests__/ActivityIndicator-test.js
@@ -6,20 +6,49 @@
*
* @format
* @emails oncall+react_native
+ * @flow
*/
'use strict';
const React = require('React');
-const ReactTestRenderer = require('react-test-renderer');
const ActivityIndicator = require('ActivityIndicator');
+const render = require('../../../../jest/renderer');
describe('ActivityIndicator', () => {
- it('renders correctly', () => {
- const instance = ReactTestRenderer.create(
+ it('should set displayName to prevent regressions', () => {
+ expect(ActivityIndicator.displayName).toBe('ActivityIndicator');
+ });
+
+ it('should render as when mocked', () => {
+ const instance = render.create(
,
);
+ expect(instance).toMatchSnapshot();
+ });
- expect(instance.toJSON()).toMatchSnapshot();
+ it('should shallow render as when mocked', () => {
+ const output = render.shallow(
+ ,
+ );
+ expect(output).toMatchSnapshot();
+ });
+
+ it('should shallow render as when not mocked', () => {
+ jest.dontMock('ActivityIndicator');
+
+ const output = render.shallow(
+ ,
+ );
+ expect(output).toMatchSnapshot();
+ });
+
+ it('should render as when not mocked', () => {
+ jest.dontMock('ActivityIndicator');
+
+ const instance = render.create(
+ ,
+ );
+ expect(instance).toMatchSnapshot();
});
});
diff --git a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap
index 8a7181882a7..d8cbec0f264 100644
--- a/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap
+++ b/Libraries/Components/ActivityIndicator/__tests__/__snapshots__/ActivityIndicator-test.js.snap
@@ -1,6 +1,6 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
-exports[`ActivityIndicator renders correctly 1`] = `
+exports[`ActivityIndicator should render as when mocked 1`] = `
`;
+
+exports[`ActivityIndicator should render as when not mocked 1`] = `
+
+
+
+`;
+
+exports[`ActivityIndicator should shallow render as when mocked 1`] = `
+
+`;
+
+exports[`ActivityIndicator should shallow render as when not mocked 1`] = `
+
+`;
diff --git a/jest/renderer.js b/jest/renderer.js
new file mode 100644
index 00000000000..e54d64d867f
--- /dev/null
+++ b/jest/renderer.js
@@ -0,0 +1,29 @@
+/**
+ * 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
+ * @emails oncall+react_native
+ * @flow
+ */
+
+'use strict';
+
+const React = require('React');
+
+const TestRenderer = require('react-test-renderer');
+const ShallowRenderer = require('react-test-renderer/shallow');
+
+const renderer = new ShallowRenderer();
+
+export const shallow = (Component: React.Element) => {
+ const Wrapper = (): React.Element => Component;
+
+ return renderer.render();
+};
+
+export const create = (Component: React.Element) => {
+ return TestRenderer.create(Component);
+};