Skip to content

Commit 5d7f35c

Browse files
sammy-SCfacebook-github-bot
authored andcommitted
add test for BaseTextProps.writingDirection (facebook#51245)
Summary: Pull Request resolved: facebook#51245 changelog: [internal] Add test to prevent facebook#51235 from happening in the future. Reviewed By: cipolleschi, rubennorte Differential Revision: D74571453 fbshipit-source-id: 49d8400543516a861c9034a8be562ee81b323c25
1 parent c9f2055 commit 5d7f35c

File tree

2 files changed

+65
-1
lines changed

2 files changed

+65
-1
lines changed
Lines changed: 64 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,64 @@
1+
/**
2+
* Copyright (c) Meta Platforms, Inc. and affiliates.
3+
*
4+
* This source code is licensed under the MIT license found in the
5+
* LICENSE file in the root directory of this source tree.
6+
*
7+
* @flow strict-local
8+
* @format
9+
* @oncall react_native
10+
*/
11+
12+
import '@react-native/fantom/src/setUpDefaultReactNativeEnvironment';
13+
14+
import * as Fantom from '@react-native/fantom';
15+
import * as React from 'react';
16+
import {Text} from 'react-native';
17+
18+
describe('<Text>', () => {
19+
describe('props', () => {
20+
describe('style', () => {
21+
describe('writingDirection', () => {
22+
it('propagates to mounting layer', () => {
23+
const root = Fantom.createRoot();
24+
25+
Fantom.runTask(() => {
26+
root.render(
27+
<Text style={{writingDirection: 'rtl'}}>dummy text</Text>,
28+
);
29+
});
30+
31+
expect(
32+
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
33+
).toEqual(
34+
<rn-paragraph writingDirection="rtl">dummy text</rn-paragraph>,
35+
);
36+
37+
Fantom.runTask(() => {
38+
root.render(
39+
<Text style={{writingDirection: 'ltr'}}>dummy text</Text>,
40+
);
41+
});
42+
43+
expect(
44+
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
45+
).toEqual(
46+
<rn-paragraph writingDirection="ltr">dummy text</rn-paragraph>,
47+
);
48+
49+
Fantom.runTask(() => {
50+
root.render(
51+
<Text style={{writingDirection: 'auto'}}>dummy text</Text>,
52+
);
53+
});
54+
55+
expect(
56+
root.getRenderedOutput({props: ['writingDirection']}).toJSX(),
57+
).toEqual(
58+
<rn-paragraph writingDirection="auto">dummy text</rn-paragraph>,
59+
);
60+
});
61+
});
62+
});
63+
});
64+
});

packages/react-native/ReactCommon/react/renderer/attributedstring/TextAttributes.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ SharedDebugStringConvertibleList TextAttributes::getDebugProps() const {
241241
debugStringConvertibleItem(
242242
"alignment", alignment, textAttributes.alignment),
243243
debugStringConvertibleItem(
244-
"baseWritingDirection",
244+
"writingDirection",
245245
baseWritingDirection,
246246
textAttributes.baseWritingDirection),
247247
debugStringConvertibleItem(

0 commit comments

Comments
 (0)