mirror of
https://github.com/facebook/react-native.git
synced 2026-11-18 20:19:07 +00:00
migrate SafeAreaView from Jest to Fantom (#56310)
Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/56310 Migrate `SafeAreaView` from Jest to Fantom. Note: SafeAreaView falls back to View in non-iOS environments, so `collapsable={false}` is needed to prevent Fantom from optimizing the view away. Changelog: [Internal] Reviewed By: cortinico Differential Revision: D99290669 fbshipit-source-id: 8beaf75c4f8237e8f8955564799fed0bbf50d25a
This commit is contained in:
1 parent
05ea94c441
commit
fd4fee0952
3 files changed
+38
-57
No files matched your search
+38
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
|
||||
|
||||
import * as Fantom from '@react-native/fantom';
|
||||
import * as React from 'react';
|
||||
import {SafeAreaView, Text} from 'react-native';
|
||||
|
||||
describe('<SafeAreaView>', () => {
|
||||
it('renders with children', () => {
|
||||
const root = Fantom.createRoot();
|
||||
|
||||
Fantom.runTask(() => {
|
||||
root.render(
|
||||
// collapsable={false} is needed to prevent the View (SafeAreaView falls
|
||||
// back to View in non-iOS environments) from being optimized away in
|
||||
// the Fantom output.
|
||||
<SafeAreaView collapsable={false}>
|
||||
<Text>Hello World!</Text>
|
||||
</SafeAreaView>,
|
||||
);
|
||||
});
|
||||
|
||||
expect(root.getRenderedOutput({props: []}).toJSX()).toEqual(
|
||||
<rn-view>
|
||||
<rn-paragraph>Hello World!</rn-paragraph>
|
||||
</rn-view>,
|
||||
);
|
||||
});
|
||||
});
|
||||
-36
@@ -1,36 +0,0 @@
|
||||
/**
|
||||
* Copyright (c) Meta Platforms, Inc. and affiliates.
|
||||
*
|
||||
* This source code is licensed under the MIT license found in the
|
||||
* LICENSE file in the root directory of this source tree.
|
||||
*
|
||||
* @flow strict-local
|
||||
* @format
|
||||
*/
|
||||
|
||||
'use strict';
|
||||
|
||||
import SafeAreaView from '../SafeAreaView';
|
||||
|
||||
const Text = require('../../../Text/Text').default;
|
||||
const ReactNativeTestTools = require('../../../Utilities/ReactNativeTestTools');
|
||||
const View = require('../../View/View').default;
|
||||
const React = require('react');
|
||||
|
||||
describe('<SafeAreaView />', () => {
|
||||
it('should render as expected', async () => {
|
||||
await ReactNativeTestTools.expectRendersMatchingSnapshot(
|
||||
'SafeAreaView',
|
||||
() => (
|
||||
<SafeAreaView>
|
||||
<View>
|
||||
<Text>Hello World!</Text>
|
||||
</View>
|
||||
</SafeAreaView>
|
||||
),
|
||||
() => {
|
||||
jest.dontMock('../SafeAreaView');
|
||||
},
|
||||
);
|
||||
});
|
||||
});
|
||||
-21
@@ -1,21 +0,0 @@
|
||||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<SafeAreaView /> should render as expected: should deep render when mocked (please verify output manually) 1`] = `
|
||||
<RCTSafeAreaView>
|
||||
<View>
|
||||
<Text>
|
||||
Hello World!
|
||||
</Text>
|
||||
</View>
|
||||
</RCTSafeAreaView>
|
||||
`;
|
||||
|
||||
exports[`<SafeAreaView /> should render as expected: should deep render when not mocked (please verify output manually) 1`] = `
|
||||
<RCTSafeAreaView>
|
||||
<View>
|
||||
<Text>
|
||||
Hello World!
|
||||
</Text>
|
||||
</View>
|
||||
</RCTSafeAreaView>
|
||||
`;
|
||||
Reference in new issue
Block a user