@@ -282,6 +282,107 @@ describe('<Image>', () => {
282282 } ,
283283 ) ;
284284 } ) ;
285+
286+ describe ( 'source' , ( ) => {
287+ it ( 'can be set to a local image' , ( ) => {
288+ const root = Fantom . createRoot ( ) ;
289+
290+ Fantom . runTask ( ( ) => {
291+ root . render ( < Image source = { require ( './img/img1.png' ) } /> ) ;
292+ } ) ;
293+
294+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
295+ < rn-image
296+ source-scale = "1"
297+ source-size = "{1, 1}"
298+ source-type = "local"
299+ source-uri = "file://drawable-mdpi/packages_reactnative_libraries_image___tests___img_img1.png"
300+ /> ,
301+ ) ;
302+ } ) ;
303+
304+ it ( 'can be set to a remote image' , ( ) => {
305+ const root = Fantom . createRoot ( ) ;
306+
307+ Fantom . runTask ( ( ) => {
308+ root . render (
309+ < Image
310+ source = { {
311+ uri : 'https://reactnative.dev/img/tiny_logo.png' ,
312+ width : 100 ,
313+ height : 100 ,
314+ scale : 2 ,
315+ cache : 'only-if-cached' ,
316+ method : 'POST' ,
317+ body : 'name=React+Native' ,
318+ headers : {
319+ Authorization : 'Basic RandomString' ,
320+ } ,
321+ } }
322+ /> ,
323+ ) ;
324+ } ) ;
325+
326+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
327+ < rn-image
328+ source-body = "name=React+Native"
329+ source-cache = "only-if-cached"
330+ source-header-Authorization = "Basic RandomString"
331+ source-method = "POST"
332+ source-scale = "2"
333+ source-size = "{100, 100}"
334+ source-type = "remote"
335+ source-uri = "https://reactnative.dev/img/tiny_logo.png"
336+ /> ,
337+ ) ;
338+ } ) ;
339+
340+ it ( 'can be set to a list of remote images' , ( ) => {
341+ const root = Fantom . createRoot ( ) ;
342+
343+ Fantom . runTask ( ( ) => {
344+ root . render (
345+ < Image
346+ source = { [
347+ {
348+ uri : 'https://reactnative.dev/img/tiny_logo.png' ,
349+ scale : 1 ,
350+ headers : {
351+ Authorization : 'Basic RandomString' ,
352+ } ,
353+ } ,
354+ {
355+ uri : 'https://reactnative.dev/img/medium_logo.png' ,
356+ scale : 2 ,
357+ cache : 'only-if-cached' ,
358+ } ,
359+ {
360+ uri : 'https://reactnative.dev/img/large_logo.png' ,
361+ scale : 3 ,
362+ method : 'POST' ,
363+ } ,
364+ ] }
365+ /> ,
366+ ) ;
367+ } ) ;
368+
369+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
370+ < rn-image
371+ source-1x-header-Authorization = "Basic RandomString"
372+ source-1x-scale = "1"
373+ source-1x-type = "remote"
374+ source-1x-uri = "https://reactnative.dev/img/tiny_logo.png"
375+ source-2x-cache = "only-if-cached"
376+ source-2x-scale = "2"
377+ source-2x-type = "remote"
378+ source-2x-uri = "https://reactnative.dev/img/medium_logo.png"
379+ source-3x-method = "POST"
380+ source-3x-type = "remote"
381+ source-3x-uri = "https://reactnative.dev/img/large_logo.png"
382+ /> ,
383+ ) ;
384+ } ) ;
385+ } ) ;
285386 } ) ;
286387
287388 describe ( 'ref' , ( ) => {
0 commit comments