@@ -19,31 +19,31 @@ import {Image} from 'react-native';
1919import ensureInstance from 'react-native/src/private/__tests__/utilities/ensureInstance' ;
2020import ReactNativeElement from 'react-native/src/private/webapis/dom/nodes/ReactNativeElement' ;
2121
22+ const LOGO_SOURCE = { uri : 'https://reactnative.dev/img/tiny_logo.png' } ;
23+
2224describe ( '<Image>' , ( ) => {
2325 describe ( 'props' , ( ) => {
24- it ( 'renders an empty element when there are no props' , ( ) => {
25- const root = Fantom . createRoot ( ) ;
26+ describe ( 'empty props' , ( ) => {
27+ // TODO T233552213: do not send empty source
28+ it ( 'renders an empty element when there are no props' , ( ) => {
29+ const root = Fantom . createRoot ( ) ;
2630
27- Fantom . runTask ( ( ) => {
28- root . render ( < Image /> ) ;
29- } ) ;
31+ Fantom . runTask ( ( ) => {
32+ root . render ( < Image /> ) ;
33+ } ) ;
34+
35+ expect ( root . getRenderedOutput ( ) . toJSX ( ) ) . toEqual (
36+ < rn-image overflow = "hidden" source-scale = "1" source-type = "remote" /> ,
37+ ) ;
38+
39+ Fantom . runTask ( ( ) => {
40+ root . render ( < Image src = "" /> ) ;
41+ } ) ;
3042
31- expect (
32- root . getRenderedOutput ( { includeLayoutMetrics : true } ) . toJSX ( ) ,
33- ) . toEqual (
34- < rn-image
35- layoutMetrics-borderWidth = "{top:0,right:0,bottom:0,left:0}"
36- layoutMetrics-contentInsets = "{top:0,right:0,bottom:0,left:0}"
37- layoutMetrics-displayType = "Flex"
38- layoutMetrics-frame = "{x:0,y:0,width:390,height:0}"
39- layoutMetrics-layoutDirection = "LeftToRight"
40- layoutMetrics-overflowInset = "{top:0,right:0,bottom:0,left:0}"
41- layoutMetrics-pointScaleFactor = "3"
42- overflow = "hidden"
43- source-scale = "1"
44- source-type = "remote"
45- /> ,
46- ) ;
43+ expect ( root . getRenderedOutput ( ) . toJSX ( ) ) . toEqual (
44+ < rn-image overflow = "hidden" source-scale = "1" source-type = "remote" /> ,
45+ ) ;
46+ } ) ;
4747 } ) ;
4848
4949 describe ( 'accessibility' , ( ) => {
@@ -123,6 +123,52 @@ describe('<Image>', () => {
123123 ) ;
124124 } ) ;
125125 } ) ;
126+
127+ describe ( 'crossOrigin' , ( ) => {
128+ it ( 'does not set any headers in anonymous mode' , ( ) => {
129+ const root = Fantom . createRoot ( ) ;
130+
131+ Fantom . runTask ( ( ) => {
132+ root . render ( < Image source = { LOGO_SOURCE } /> ) ;
133+ } ) ;
134+
135+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
136+ < rn-image
137+ source-scale = "1"
138+ source-type = "remote"
139+ source-uri = { LOGO_SOURCE . uri }
140+ /> ,
141+ ) ;
142+
143+ Fantom . runTask ( ( ) => {
144+ root . render ( < Image crossOrigin = "anonymous" source = { LOGO_SOURCE } /> ) ;
145+ } ) ;
146+
147+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
148+ < rn-image
149+ source-scale = "1"
150+ source-type = "remote"
151+ source-uri = { LOGO_SOURCE . uri }
152+ /> ,
153+ ) ;
154+ } ) ;
155+
156+ it ( 'sets the "Access-Control-Allow-Credentials" header in "use-credentials" mode' , ( ) => {
157+ const root = Fantom . createRoot ( ) ;
158+
159+ Fantom . runTask ( ( ) => {
160+ root . render (
161+ < Image crossOrigin = "use-credentials" source = { LOGO_SOURCE } /> ,
162+ ) ;
163+ } ) ;
164+
165+ expect (
166+ root . getRenderedOutput ( { props : [ 'source-header' ] } ) . toJSX ( ) ,
167+ ) . toEqual (
168+ < rn-image source-header-Access-Control-Allow-Credentials = "true" /> ,
169+ ) ;
170+ } ) ;
171+ } ) ;
126172 } ) ;
127173
128174 describe ( 'ref' , ( ) => {
0 commit comments