diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-itest.js b/packages/react-native/Libraries/Components/View/__tests__/View-itest.js new file mode 100644 index 00000000000..faf23d4e17b --- /dev/null +++ b/packages/react-native/Libraries/Components/View/__tests__/View-itest.js @@ -0,0 +1,181 @@ +/** + * 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 + * @oncall react_native + */ + +import '../../../Core/InitializeCore.js'; + +import * as Fantom from '@react-native/fantom'; +import * as React from 'react'; + +const View = require('../View'); + +describe('width and height style', () => { + it('handles correct percentage-based dimensions', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + expect( + root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), + ).toEqual( + , + ); + + root.destroy(); + }); + + it('handles numeric values passed in as strings', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + , + ); + }); + + expect( + root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), + ).toEqual( + , + ); + + root.destroy(); + }); + + it('handles invalid values, falling back to default', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + expect( + root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), + ).toEqual( + , + ); + + root.destroy(); + }); +}); + +describe('margin style', () => { + it('handles correct percentage-based values', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + expect( + root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), + ).toEqual( + , + ); + + root.destroy(); + }); + + it('handles numeric values passed in as strings', () => { + const root = Fantom.createRoot(); + + Fantom.runTask(() => { + root.render( + + + , + ); + }); + + expect( + root.getRenderedOutput({includeLayoutMetrics: true}).toJSX(), + ).toEqual( + , + ); + + root.destroy(); + }); +});