@@ -463,12 +463,13 @@ describe('kitsu-core', () => {
463463 expect ( input ) . toEqual ( { data : resourceOutput } )
464464 } )
465465
466- it ( 'uses the new system ' , ( ) => {
466+ it ( 'serialises object and array relationships ' , ( ) => {
467467 expect . assertions ( 1 )
468468 const input = {
469469 id : '1' ,
470470 type : 'libraryEntries' ,
471471 links : { self : 'library-entries/1' } ,
472+ meta : { extra : true } ,
472473 ratingTwenty : 10 ,
473474 user : {
474475 links : {
@@ -504,6 +505,7 @@ describe('kitsu-core', () => {
504505 id : '1' ,
505506 type : 'libraryEntries' ,
506507 links : { self : 'library-entries/1' } ,
508+ meta : { extra : true } ,
507509 attributes : { ratingTwenty : 10 } ,
508510 relationships : {
509511 user : {
@@ -539,5 +541,45 @@ describe('kitsu-core', () => {
539541 }
540542 expect ( serialise ( 'libraryEntries' , input ) ) . toStrictEqual ( output )
541543 } )
544+
545+ it ( 'keeps non-JSON:API links/meta properties in attributes' , ( ) => {
546+ expect . assertions ( 1 )
547+ const input = {
548+ id : '1' ,
549+ type : 'libraryEntries' ,
550+ links : 'Not JSON:API link object' ,
551+ meta : 'Not JSON:API meta object' ,
552+ user : {
553+ data : {
554+ id : '1' ,
555+ links : 'Not JSON:API link object' ,
556+ meta : 'Not JSON:API meta object'
557+ }
558+ }
559+ }
560+ const output = {
561+ data : {
562+ id : '1' ,
563+ type : 'libraryEntries' ,
564+ attributes : {
565+ links : 'Not JSON:API link object' ,
566+ meta : 'Not JSON:API meta object'
567+ } ,
568+ relationships : {
569+ user : {
570+ data : {
571+ id : '1' ,
572+ type : 'user' ,
573+ attributes : {
574+ links : 'Not JSON:API link object' ,
575+ meta : 'Not JSON:API meta object'
576+ }
577+ }
578+ }
579+ }
580+ }
581+ }
582+ expect ( serialise ( 'libraryEntries' , input ) ) . toStrictEqual ( output )
583+ } )
542584 } )
543585} )
0 commit comments