@@ -130,7 +130,7 @@ impl From<&Cell> for MediaCellData {
130130impl From < MediaCellData > for Cell {
131131 fn from ( value : MediaCellData ) -> Self {
132132 let mut cell = new_cell_builder ( FieldType :: Media ) ;
133- cell. insert ( CELL_DATA . into ( ) , value. to_string ( ) . into ( ) ) ;
133+ cell. insert ( CELL_DATA . into ( ) , value. into ( ) ) ;
134134 cell
135135 }
136136}
@@ -575,4 +575,38 @@ mod tests {
575575
576576 assert_eq ! ( numeric_value, Some ( 123.45 ) ) ;
577577 }
578+
579+ #[ test]
580+ fn test_media_cell_data_to_and_from_cell ( ) {
581+ // Create MediaCellData with sample MediaFile entries
582+ let media_file_1 = MediaFile :: new (
583+ "file1.jpg" . to_string ( ) ,
584+ "http://example.com/file1.jpg" . to_string ( ) ,
585+ MediaUploadType :: Local ,
586+ MediaFileType :: Image ,
587+ ) ;
588+ let media_file_2 = MediaFile :: new (
589+ "file2.png" . to_string ( ) ,
590+ "http://example.com/file2.png" . to_string ( ) ,
591+ MediaUploadType :: Cloud ,
592+ MediaFileType :: Image ,
593+ ) ;
594+
595+ let media_cell_data = MediaCellData {
596+ files : vec ! [ media_file_1. clone( ) , media_file_2. clone( ) ] ,
597+ } ;
598+
599+ // Convert MediaCellData to a Cell
600+ let cell: Cell = media_cell_data. clone ( ) . into ( ) ;
601+
602+ // Assert the Cell has the correct field type and content
603+ let cell_data = MediaCellData :: from ( & cell) ;
604+ cell_data
605+ . files
606+ . iter ( )
607+ . zip ( media_cell_data. files . iter ( ) )
608+ . for_each ( |( a, b) | {
609+ assert_eq ! ( a, b) ;
610+ } ) ;
611+ }
578612}
0 commit comments