Skip to content

Commit 457190c

Browse files
andrewdacenkofacebook-github-bot
authored andcommitted
Add test for width, style, testID and tintColor (#53088)
Summary: Pull Request resolved: #53088 Changelog: [Internal] As title Reviewed By: rshest Differential Revision: D79642765 fbshipit-source-id: 92862934fc72cfca2ce35c365fa7369d878d58d9
1 parent 6965d57 commit 457190c

2 files changed

Lines changed: 75 additions & 0 deletions

File tree

packages/react-native/Libraries/Image/__tests__/Image-itest.js

Lines changed: 73 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,20 @@ describe('<Image>', () => {
208208
});
209209
});
210210

211+
describe('width', () => {
212+
it('provides width for image', () => {
213+
const root = Fantom.createRoot();
214+
215+
Fantom.runTask(() => {
216+
root.render(<Image width={100} source={LOGO_SOURCE} />);
217+
});
218+
219+
expect(root.getRenderedOutput({props: ['width']}).toJSX()).toEqual(
220+
<rn-image width="100.000000" />,
221+
);
222+
});
223+
});
224+
211225
describe('loading progress', () => {
212226
(
213227
[
@@ -550,6 +564,65 @@ describe('<Image>', () => {
550564
);
551565
});
552566
});
567+
568+
describe('style', () => {
569+
it('can be set', () => {
570+
const root = Fantom.createRoot();
571+
572+
Fantom.runTask(() => {
573+
root.render(
574+
<Image
575+
style={{
576+
width: 100,
577+
height: 100,
578+
resizeMode: 'contain',
579+
}}
580+
source={LOGO_SOURCE}
581+
/>,
582+
);
583+
});
584+
585+
expect(root.getRenderedOutput().toJSX()).toEqual(
586+
<rn-image
587+
height="100.000000"
588+
overflow="hidden"
589+
resizeMode="contain"
590+
width="100.000000"
591+
source-scale="1"
592+
source-type="remote"
593+
source-uri="https://reactnative.dev/img/tiny_logo.png"
594+
/>,
595+
);
596+
});
597+
});
598+
599+
describe('testID', () => {
600+
it('can be set', () => {
601+
const root = Fantom.createRoot();
602+
603+
Fantom.runTask(() => {
604+
root.render(<Image testID="test" source={LOGO_SOURCE} />);
605+
});
606+
607+
expect(root.getRenderedOutput({props: ['testID']}).toJSX()).toEqual(
608+
<rn-image testID="test" />,
609+
);
610+
});
611+
});
612+
613+
describe('tintColor', () => {
614+
it('can be set', () => {
615+
const root = Fantom.createRoot();
616+
617+
Fantom.runTask(() => {
618+
root.render(<Image tintColor="red" source={LOGO_SOURCE} />);
619+
});
620+
621+
expect(root.getRenderedOutput({props: ['tintColor']}).toJSX()).toEqual(
622+
<rn-image tintColor="rgba(255, 0, 0, 1)" />,
623+
);
624+
});
625+
});
553626
});
554627

555628
describe('ref', () => {

packages/react-native/ReactCommon/react/renderer/components/image/ImageProps.cpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -308,6 +308,8 @@ SharedDebugStringConvertibleList ImageProps::getDebugProps() const {
308308
"resizeMode",
309309
toString(resizeMode),
310310
toString(imageProps.resizeMode)),
311+
debugStringConvertibleItem(
312+
"tintColor", toString(tintColor), toString(imageProps.tintColor)),
311313
};
312314
}
313315

0 commit comments

Comments
 (0)