Skip to content

Commit 0dda0fe

Browse files
committed
test: add test for empty to-one/to-many relationship serialisation
1 parent 7ad3dfc commit 0dda0fe

1 file changed

Lines changed: 46 additions & 0 deletions

File tree

packages/kitsu-core/src/serialise/index.spec.js

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -581,5 +581,51 @@ describe('kitsu-core', () => {
581581
}
582582
expect(serialise('libraryEntries', input)).toStrictEqual(output)
583583
})
584+
585+
it('deletes a to-one relationship', () => {
586+
expect.assertions(1)
587+
const input = {
588+
id: '1',
589+
type: 'libraryEntries',
590+
user: {
591+
data: null
592+
}
593+
}
594+
const output = {
595+
data: {
596+
id: '1',
597+
type: 'libraryEntries',
598+
relationships: {
599+
user: {
600+
data: null
601+
}
602+
}
603+
}
604+
}
605+
expect(serialise('libraryEntries', input)).toStrictEqual(output)
606+
})
607+
608+
it('deletes a to-many relationship', () => {
609+
expect.assertions(1)
610+
const input = {
611+
id: '1',
612+
type: 'libraryEntries',
613+
user: {
614+
data: []
615+
}
616+
}
617+
const output = {
618+
data: {
619+
id: '1',
620+
type: 'libraryEntries',
621+
relationships: {
622+
user: {
623+
data: []
624+
}
625+
}
626+
}
627+
}
628+
expect(serialise('libraryEntries', input)).toStrictEqual(output)
629+
})
584630
})
585631
})

0 commit comments

Comments
 (0)