base.spec.ts 1.2 KB

12345678910111213141516171819202122232425
  1. /**
  2. * The bundle's substance is its patch file: the `dsh.bundle.patch` manifest
  3. * field must name a real, parseable patch list.
  4. */
  5. import { readFileSync } from 'node:fs'
  6. import { fileURLToPath } from 'node:url'
  7. import { resolve } from 'node:path'
  8. import { describe, expect, it } from 'vitest'
  9. import * as yaml from 'js-yaml'
  10. import { entryListSchema } from '@cordisjs/plugin-include'
  11. describe('dsh-base bundle', () => {
  12. it('declares a parseable patch list through the dsh.bundle.patch manifest field', () => {
  13. const root = fileURLToPath(new URL('..', import.meta.url))
  14. const manifest = JSON.parse(readFileSync(resolve(root, 'package.json'), 'utf8')) as { dsh?: { bundle?: { patch?: string } } }
  15. expect(manifest.dsh?.bundle?.patch).toBe('./cordis.patch.yml')
  16. const parsed = yaml.load(readFileSync(resolve(root, manifest.dsh!.bundle!.patch!), 'utf8'), { schema: entryListSchema })
  17. expect(Array.isArray(parsed)).toBe(true)
  18. // The base layer is one insert list over the empty profile root.
  19. const rows = (parsed as { insert?: { id?: string }[] }[]).flatMap(patch => patch.insert ?? [])
  20. expect(rows.length).toBeGreaterThan(50)
  21. expect(rows.some(row => row.id === 'agent-loop')).toBe(true)
  22. })
  23. })