From 68e5a24ef715ca0d8108e5ce9689dd96a8fe21a5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rub=C3=A9n=20Norte?= Date: Fri, 1 Aug 2025 10:33:01 -0700 Subject: [PATCH] Restructure Fantom test for View to follow convention (#52983) Summary: Pull Request resolved: https://github.com/facebook/react-native/pull/52983 Changelog: [internal] Just moving some tests that were defined under `` that were related to styles, to under ` > props > style`. Reviewed By: rshest Differential Revision: D79447450 fbshipit-source-id: e97cc4e058ffc8170b7fa74176cc8dc27e26cfde --- .../Components/View/__tests__/View-itest.js | 395 +++++++++--------- 1 file changed, 202 insertions(+), 193 deletions(-) diff --git a/packages/react-native/Libraries/Components/View/__tests__/View-itest.js b/packages/react-native/Libraries/Components/View/__tests__/View-itest.js index 77ff853ecb3..c9b92c92ba3 100644 --- a/packages/react-native/Libraries/Components/View/__tests__/View-itest.js +++ b/packages/react-native/Libraries/Components/View/__tests__/View-itest.js @@ -20,209 +20,217 @@ import {View} from 'react-native'; import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement'; describe('', () => { - describe('width and height style', () => { - it('handles correct percentage-based dimensions', () => { - const root = Fantom.createRoot(); + describe('props', () => { + describe('style', () => { + describe('width and height style', () => { + it('handles correct percentage-based dimensions', () => { + const root = Fantom.createRoot(); - Fantom.runTask(() => { - root.render( - - - , - ); - }); + 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: true}).toJSX(), - ).toEqual( - , - ); - }); - - it('handles invalid values, falling back to default', () => { - const root = Fantom.createRoot(); - - Fantom.runTask(() => { - root.render( - - - , - ); - }); - - expect( - root.getRenderedOutput({includeLayoutMetrics: true}).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: true}).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( - , - ); - }); - - [ - [undefined, {x: -5, y: 0, width: 20, height: 10}], - ['50% 50%', {x: -5, y: 0, width: 20, height: 10}], - ['top left', {x: 0, y: 0, width: 20, height: 10}], - ['right bottom', {x: -10, y: 0, width: 20, height: 10}], - ].forEach(([transformOrigin, expectedBounds]) => { - it(`applies transformOrigin correctly for ${String(transformOrigin)}`, () => { - const root = Fantom.createRoot(); - - const viewRef = createRef(); - Fantom.runTask(() => { - root.render( - , ); }); - const viewElement = ensureInstance(viewRef.current, ReactNativeElement); + it('handles numeric values passed in as strings', () => { + const root = Fantom.createRoot(); - const viewBounds = viewElement.getBoundingClientRect(); - expect(viewBounds.x).toBe(expectedBounds.x); - expect(viewBounds.y).toBe(expectedBounds.y); - expect(viewBounds.width).toBe(expectedBounds.width); - expect(viewBounds.height).toBe(expectedBounds.height); + 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: true}).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: true}).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(); + }); + + [ + [undefined, {x: -5, y: 0, width: 20, height: 10}], + ['50% 50%', {x: -5, y: 0, width: 20, height: 10}], + ['top left', {x: 0, y: 0, width: 20, height: 10}], + ['right bottom', {x: -10, y: 0, width: 20, height: 10}], + ].forEach(([transformOrigin, expectedBounds]) => { + it(`applies transformOrigin correctly for ${String(transformOrigin)}`, () => { + const root = Fantom.createRoot(); + + const viewRef = createRef(); + Fantom.runTask(() => { + root.render( + , + ); + }); + + const viewElement = ensureInstance( + viewRef.current, + ReactNativeElement, + ); + + const viewBounds = viewElement.getBoundingClientRect(); + expect(viewBounds.x).toBe(expectedBounds.x); + expect(viewBounds.y).toBe(expectedBounds.y); + expect(viewBounds.width).toBe(expectedBounds.width); + expect(viewBounds.height).toBe(expectedBounds.height); + }); + }); }); }); - }); - describe('props', () => { describe('pointerEvents', () => { it('auto does not propagate to the mounting layer, it is the default', () => { const root = Fantom.createRoot(); @@ -285,6 +293,7 @@ describe('', () => { ).toEqual(); }); }); + describe('accessibility', () => { describe('accessibilityActions', () => { it('is propagated to the mounting layer', () => {