fix: resolve selected winners from populated CMS data
This commit is contained in:
25
tests/int/cms-route-relationship.int.spec.ts
Normal file
25
tests/int/cms-route-relationship.int.spec.ts
Normal file
@@ -0,0 +1,25 @@
|
||||
import { describe, expect, it } from 'vitest'
|
||||
|
||||
import { resolveCmsRelationship, type CmsRouteDoc } from '@/spa/cmsRoute'
|
||||
|
||||
const fullWinner: CmsRouteDoc = {
|
||||
id: 20,
|
||||
title: 'Adelholzener Alpenquellen GmbH',
|
||||
image: { id: 55, url: '/api/media/file/image%20(1).png' },
|
||||
}
|
||||
|
||||
describe('CMS relationship resolution', () => {
|
||||
it('prefers the fully populated collection document over a shallow relationship object', () => {
|
||||
expect(resolveCmsRelationship({ id: 20, image: 55 }, [fullWinner])).toBe(fullWinner)
|
||||
})
|
||||
|
||||
it('resolves an ID-only relationship', () => {
|
||||
expect(resolveCmsRelationship(20, [fullWinner])).toBe(fullWinner)
|
||||
})
|
||||
|
||||
it('preserves a populated relationship when no list document is available', () => {
|
||||
const relationship = { id: 20, image: { id: 55, url: '/api/media/file/image%20(1).png' } }
|
||||
|
||||
expect(resolveCmsRelationship(relationship, [])).toBe(relationship)
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user