@@ -328,6 +328,107 @@ describe('<Image>', () => {
328328 } ,
329329 ) ;
330330 } ) ;
331+
332+ describe ( 'source' , ( ) => {
333+ it ( 'can be set to a local image' , ( ) => {
334+ const root = Fantom . createRoot ( ) ;
335+
336+ Fantom . runTask ( ( ) => {
337+ root . render ( < Image source = { require ( './img/img1.png' ) } /> ) ;
338+ } ) ;
339+
340+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
341+ < rn-image
342+ source-scale = "1"
343+ source-size = "{1, 1}"
344+ source-type = "local"
345+ source-uri = "file://drawable-mdpi/packages_reactnative_libraries_image___tests___img_img1.png"
346+ /> ,
347+ ) ;
348+ } ) ;
349+
350+ it ( 'can be set to a remote image' , ( ) => {
351+ const root = Fantom . createRoot ( ) ;
352+
353+ Fantom . runTask ( ( ) => {
354+ root . render (
355+ < Image
356+ source = { {
357+ uri : 'https://reactnative.dev/img/tiny_logo.png' ,
358+ width : 100 ,
359+ height : 100 ,
360+ scale : 2 ,
361+ cache : 'only-if-cached' ,
362+ method : 'POST' ,
363+ body : 'name=React+Native' ,
364+ headers : {
365+ Authorization : 'Basic RandomString' ,
366+ } ,
367+ } }
368+ /> ,
369+ ) ;
370+ } ) ;
371+
372+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
373+ < rn-image
374+ source-body = "name=React+Native"
375+ source-cache = "only-if-cached"
376+ source-header-Authorization = "Basic RandomString"
377+ source-method = "POST"
378+ source-scale = "2"
379+ source-size = "{100, 100}"
380+ source-type = "remote"
381+ source-uri = "https://reactnative.dev/img/tiny_logo.png"
382+ /> ,
383+ ) ;
384+ } ) ;
385+
386+ it ( 'can be set to a list of remote images' , ( ) => {
387+ const root = Fantom . createRoot ( ) ;
388+
389+ Fantom . runTask ( ( ) => {
390+ root . render (
391+ < Image
392+ source = { [
393+ {
394+ uri : 'https://reactnative.dev/img/tiny_logo.png' ,
395+ scale : 1 ,
396+ headers : {
397+ Authorization : 'Basic RandomString' ,
398+ } ,
399+ } ,
400+ {
401+ uri : 'https://reactnative.dev/img/medium_logo.png' ,
402+ scale : 2 ,
403+ cache : 'only-if-cached' ,
404+ } ,
405+ {
406+ uri : 'https://reactnative.dev/img/large_logo.png' ,
407+ scale : 3 ,
408+ method : 'POST' ,
409+ } ,
410+ ] }
411+ /> ,
412+ ) ;
413+ } ) ;
414+
415+ expect ( root . getRenderedOutput ( { props : [ 'source' ] } ) . toJSX ( ) ) . toEqual (
416+ < rn-image
417+ source-1x-header-Authorization = "Basic RandomString"
418+ source-1x-scale = "1"
419+ source-1x-type = "remote"
420+ source-1x-uri = "https://reactnative.dev/img/tiny_logo.png"
421+ source-2x-cache = "only-if-cached"
422+ source-2x-scale = "2"
423+ source-2x-type = "remote"
424+ source-2x-uri = "https://reactnative.dev/img/medium_logo.png"
425+ source-3x-method = "POST"
426+ source-3x-type = "remote"
427+ source-3x-uri = "https://reactnative.dev/img/large_logo.png"
428+ /> ,
429+ ) ;
430+ } ) ;
431+ } ) ;
331432 } ) ;
332433
333434 describe ( 'ref' , ( ) => {
0 commit comments