42 lines
1.1 KiB
TypeScript
42 lines
1.1 KiB
TypeScript
import payload from '../../packages/payload/src'
|
|
import { initPayloadTest } from '../helpers/configHelpers'
|
|
|
|
describe('Nested Docs', () => {
|
|
beforeAll(async () => {
|
|
await initPayloadTest({ __dirname, init: { local: true } })
|
|
})
|
|
|
|
describe('seed', () => {
|
|
it('should populate two levels of breadcrumbs', async () => {
|
|
const query = await payload.find({
|
|
collection: 'pages',
|
|
where: {
|
|
slug: {
|
|
equals: 'child-page',
|
|
},
|
|
},
|
|
})
|
|
|
|
expect(query.docs[0].breadcrumbs).toHaveLength(2)
|
|
})
|
|
|
|
it('should populate three levels of breadcrumbs', async () => {
|
|
const query = await payload.find({
|
|
collection: 'pages',
|
|
where: {
|
|
slug: {
|
|
equals: 'grandchild-page',
|
|
},
|
|
},
|
|
})
|
|
|
|
expect(query.docs[0].breadcrumbs).toHaveLength(3)
|
|
expect(query.docs[0].breadcrumbs[0].url).toStrictEqual('/parent-page')
|
|
expect(query.docs[0].breadcrumbs[1].url).toStrictEqual('/parent-page/child-page')
|
|
expect(query.docs[0].breadcrumbs[2].url).toStrictEqual(
|
|
'/parent-page/child-page/grandchild-page',
|
|
)
|
|
})
|
|
})
|
|
})
|