import { ComponentType, type MarkdownComponent } from '@defra/forms-model' import { ComponentCollection } from '~/src/server/plugins/engine/components/ComponentCollection.js' import { type Guidance } from '~/src/server/plugins/engine/components/helpers/components.js' import { FormModel } from '~/src/server/plugins/engine/models/FormModel.js' import definition from '~/test/form/definitions/basic.js' describe('Markdown', () => { let model: FormModel beforeEach(() => { model = new FormModel(definition, { basePath: 'test' }) }) describe('Defaults', () => { let def: MarkdownComponent let collection: ComponentCollection let guidance: Guidance beforeEach(() => { def = { title: 'Markdown guidance', name: 'myComponent', type: ComponentType.Markdown, content: '# Heading 1 ## Heading 2', options: {} } satisfies MarkdownComponent collection = new ComponentCollection([def], { model }) guidance = collection.guidance[0] }) describe('View model', () => { it('sets Nunjucks component defaults', () => { const viewModel = guidance.getViewModel() expect(viewModel).toEqual( expect.objectContaining({ attributes: {}, content: def.content }) ) }) }) }) })