@@ -346,5 +346,345 @@ describe('kitsu-core', () => {
346346 }
347347 } )
348348 } )
349+
350+ it ( 'does not overwrite meta objects' , ( ) => {
351+ expect . assertions ( 1 )
352+ const data = {
353+ type : 'node--article' ,
354+ id : '1' ,
355+ attributes : {
356+ field_slug : 'Tower of Pisa' ,
357+ field_standfirst : 'Article standfirst' ,
358+ quote : 'Example quote' ,
359+ quote_byline : 'Example source' ,
360+ last_revision_username : 'apisrijanstuff' ,
361+ stuff_asset_id : '600007070'
362+ } ,
363+ relationships : {
364+ field_content : {
365+ data : [
366+ {
367+ type : 'paragraph--assets' ,
368+ id : '6e0eca07-bc2e-4b2a-af42-7fc58138cb68' ,
369+ meta : {
370+ target_revision_id : 84829 ,
371+ drupal_internal__target_id : 46287
372+ }
373+ }
374+
375+ ]
376+ } ,
377+ field_teaser : {
378+ data : {
379+ type : 'paragraph--teaser' ,
380+ id : '1b578e46-d0fb-4411-919a-aae07d70b5b0' ,
381+ meta : {
382+ target_revision_id : 84822 ,
383+ drupal_internal__target_id : 46280
384+ }
385+ }
386+ }
387+ }
388+ }
389+ const included = [
390+ {
391+ type : 'paragraph--assets' ,
392+ id : '6e0eca07-bc2e-4b2a-af42-7fc58138cb68' ,
393+ attributes : {
394+ drupal_internal__id : 46287 ,
395+ drupal_internal__revision_id : 84829 ,
396+ status : true ,
397+ created : '2022-10-18T19:39:54+13:00' ,
398+ parent_id : '4382' ,
399+ parent_type : 'node' ,
400+ parent_field_name : 'field_content' ,
401+ behavior_settings : [
402+
403+ ]
404+ } ,
405+ relationships : {
406+ field_media_override : {
407+ data : {
408+ type : 'media--image' ,
409+ id : '842b1824-2982-4fcb-8dc7-780c1ae71d81' ,
410+ meta : {
411+ value : {
412+ original : 'https://platform-admin-stage-media.staging.nebula-drupal.stuff.co.nz/s3fs-public/2022-10/eSO6cM0L8_-Zy6fFR0GXNaBNUg0_1.jpg' ,
413+ crop_1_1 : {
414+ width : '100' ,
415+ height : '100' ,
416+ x : '10' ,
417+ y : '10'
418+ }
419+ } ,
420+ caption : 'Image Caption' ,
421+ alt_txt : 'Image Alt' ,
422+ credit : 'Image Credit' ,
423+ author : '' ,
424+ source : '' ,
425+ focal_point : '10,10' ,
426+ crop_used : '' ,
427+ drupal_internal__target_id : 3775
428+ }
429+ }
430+ }
431+ }
432+ } ,
433+ {
434+ type : 'paragraph--teaser' ,
435+ id : '1b578e46-d0fb-4411-919a-aae07d70b5b0' ,
436+ attributes : {
437+ drupal_internal__id : 46280 ,
438+ drupal_internal__revision_id : 84822 ,
439+ status : true ,
440+ created : '2022-10-18T19:39:54+13:00' ,
441+ parent_id : '4382' ,
442+ parent_type : 'node' ,
443+ parent_field_name : 'field_teaser' ,
444+ behavior_settings : [
445+
446+ ] ,
447+ field_intro : 'Teaser Intro' ,
448+ field_teaser_headline : 'Teaser Short Headline'
449+ } ,
450+ relationships : {
451+ field_media_override : {
452+ data : {
453+ type : 'media--image' ,
454+ id : '842b1824-2982-4fcb-8dc7-780c1ae71d81' ,
455+ meta : {
456+ value : {
457+ original : 'https://platform-admin-stage-media.staging.nebula-drupal.stuff.co.nz/s3fs-public/2022-10/eSO6cM0L8_-Zy6fFR0GXNaBNUg0_1.jpg' ,
458+ crop_1_1 : {
459+ width : '100' ,
460+ height : '100' ,
461+ x : '50' ,
462+ y : '50'
463+ }
464+ } ,
465+ caption : 'Image Caption' ,
466+ alt_txt : 'coronetpeak.jpeg' ,
467+ credit : '' ,
468+ author : '' ,
469+ source : '' ,
470+ focal_point : '20,20' ,
471+ crop_used : '' ,
472+ drupal_internal__target_id : 3775
473+ }
474+ }
475+ }
476+ }
477+ } ,
478+ {
479+ type : 'media--image' ,
480+ id : '842b1824-2982-4fcb-8dc7-780c1ae71d81' ,
481+ attributes : {
482+ drupal_internal__mid : 3775 ,
483+ drupal_internal__vid : 3757 ,
484+ status : true ,
485+ name : 'coronetpeak.jpeg' ,
486+ created : '2022-10-18T15:47:12+13:00' ,
487+ changed : '2022-10-19T12:41:38+13:00'
488+
489+ } ,
490+ relationships : {
491+ thumbnail : {
492+ data : {
493+ type : 'file--file' ,
494+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
495+ meta : {
496+ alt : 'coronetpeak.jpeg' ,
497+ title : null ,
498+ width : 1340 ,
499+ height : 876
500+ }
501+ }
502+ } ,
503+ field_media_image : {
504+ data : {
505+ type : 'file--file' ,
506+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
507+ meta : {
508+ alt : 'coronetpeak.jpeg' ,
509+ title : null ,
510+ width : 1340 ,
511+ height : 876
512+ }
513+ }
514+ }
515+ }
516+ }
517+ ]
518+ expect ( linkRelationships ( data , included ) ) . toStrictEqual (
519+
520+ {
521+ type : 'node--article' ,
522+ id : '1' ,
523+ attributes : {
524+ field_slug : 'Tower of Pisa' ,
525+ field_standfirst : 'Article standfirst' ,
526+ quote : 'Example quote' ,
527+ quote_byline : 'Example source' ,
528+ last_revision_username : 'apisrijanstuff' ,
529+ stuff_asset_id : '600007070'
530+ } ,
531+ field_content : {
532+ data : [
533+ {
534+ type : 'paragraph--assets' ,
535+ id : '6e0eca07-bc2e-4b2a-af42-7fc58138cb68' ,
536+ field_media_override : {
537+ data : {
538+ type : 'media--image' ,
539+ id : '842b1824-2982-4fcb-8dc7-780c1ae71d81' ,
540+ thumbnail : {
541+ data : {
542+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
543+ type : 'file--file' ,
544+ meta : {
545+ alt : 'coronetpeak.jpeg' ,
546+ title : null ,
547+ width : 1340 ,
548+ height : 876
549+ }
550+ }
551+ } ,
552+ field_media_image : {
553+ data : {
554+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
555+ type : 'file--file' ,
556+ meta : {
557+ alt : 'coronetpeak.jpeg' ,
558+ title : null ,
559+ width : 1340 ,
560+ height : 876
561+ }
562+ }
563+ } ,
564+ meta : {
565+ value : {
566+ original : 'https://platform-admin-stage-media.staging.nebula-drupal.stuff.co.nz/s3fs-public/2022-10/eSO6cM0L8_-Zy6fFR0GXNaBNUg0_1.jpg' ,
567+ crop_1_1 : {
568+ width : '100' ,
569+ height : '100' ,
570+ x : '10' ,
571+ y : '10'
572+ }
573+ } ,
574+ caption : 'Image Caption' ,
575+ alt_txt : 'Image Alt' ,
576+ credit : 'Image Credit' ,
577+ author : '' ,
578+ source : '' ,
579+ focal_point : '10,10' ,
580+ crop_used : '' ,
581+ drupal_internal__target_id : 3775
582+ } ,
583+ drupal_internal__mid : 3775 ,
584+ drupal_internal__vid : 3757 ,
585+ status : true ,
586+ name : 'coronetpeak.jpeg' ,
587+ created : '2022-10-18T15:47:12+13:00' ,
588+ changed : '2022-10-19T12:41:38+13:00'
589+ }
590+ } ,
591+ meta : {
592+ target_revision_id : 84829 ,
593+ drupal_internal__target_id : 46287
594+ } ,
595+ drupal_internal__id : 46287 ,
596+ drupal_internal__revision_id : 84829 ,
597+ status : true ,
598+ created : '2022-10-18T19:39:54+13:00' ,
599+ parent_id : '4382' ,
600+ parent_type : 'node' ,
601+ parent_field_name : 'field_content' ,
602+ behavior_settings : [
603+
604+ ]
605+ }
606+ ]
607+ } ,
608+ field_teaser : {
609+ data : {
610+ type : 'paragraph--teaser' ,
611+ id : '1b578e46-d0fb-4411-919a-aae07d70b5b0' ,
612+ field_media_override : {
613+ data : {
614+ type : 'media--image' ,
615+ id : '842b1824-2982-4fcb-8dc7-780c1ae71d81' ,
616+ thumbnail : {
617+ data : {
618+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
619+ type : 'file--file' ,
620+ meta : {
621+ alt : 'coronetpeak.jpeg' ,
622+ title : null ,
623+ width : 1340 ,
624+ height : 876
625+ }
626+ }
627+ } ,
628+ field_media_image : {
629+ data : {
630+ id : '2025398c-0197-4728-800b-21e4b96644e7' ,
631+ type : 'file--file' ,
632+ meta : {
633+ alt : 'coronetpeak.jpeg' ,
634+ title : null ,
635+ width : 1340 ,
636+ height : 876
637+ }
638+ }
639+ } ,
640+ meta : {
641+ value : {
642+ original : 'https://platform-admin-stage-media.staging.nebula-drupal.stuff.co.nz/s3fs-public/2022-10/eSO6cM0L8_-Zy6fFR0GXNaBNUg0_1.jpg' ,
643+ crop_1_1 : {
644+ width : '100' ,
645+ height : '100' ,
646+ x : '50' ,
647+ y : '50'
648+ }
649+ } ,
650+ caption : 'Image Caption' ,
651+ alt_txt : 'coronetpeak.jpeg' ,
652+ credit : '' ,
653+ author : '' ,
654+ source : '' ,
655+ focal_point : '20,20' ,
656+ crop_used : '' ,
657+ drupal_internal__target_id : 3775
658+ } ,
659+ drupal_internal__mid : 3775 ,
660+ drupal_internal__vid : 3757 ,
661+ status : true ,
662+ name : 'coronetpeak.jpeg' ,
663+ created : '2022-10-18T15:47:12+13:00' ,
664+ changed : '2022-10-19T12:41:38+13:00'
665+ }
666+ } ,
667+ meta : {
668+ target_revision_id : 84822 ,
669+ drupal_internal__target_id : 46280
670+ } ,
671+ drupal_internal__id : 46280 ,
672+ drupal_internal__revision_id : 84822 ,
673+ status : true ,
674+ created : '2022-10-18T19:39:54+13:00' ,
675+ parent_id : '4382' ,
676+ parent_type : 'node' ,
677+ parent_field_name : 'field_teaser' ,
678+ behavior_settings : [
679+
680+ ] ,
681+ field_intro : 'Teaser Intro' ,
682+ field_teaser_headline : 'Teaser Short Headline'
683+ }
684+ }
685+ }
686+
687+ )
688+ } )
349689 } )
350690} )
0 commit comments