Files
mdm-ordinis/ordinis-admin-ui/src/components/workflow/pickSeedSchema.test.ts
T

24 lines
930 B
TypeScript

import { describe, expect, it } from 'vitest'
import type { SchemaDraft } from '@/api/client'
import { pickSeedSchema } from './CreateSchemaDraftModal'
const draft = (proposed: unknown): SchemaDraft =>
({ proposedSchema: proposed } as unknown as SchemaDraft)
describe('pickSeedSchema', () => {
it('edit-mode draft wins over pre-fill and live HEAD', () => {
const seed = pickSeedSchema(draft({ type: 'edit' }), { type: 'pre-fill' }, { type: 'head' })
expect(seed).toEqual({ type: 'edit' })
})
it('caller pre-fill wins over live HEAD when no edit-mode draft', () => {
const seed = pickSeedSchema(undefined, { type: 'pre-fill' }, { type: 'head' })
expect(seed).toEqual({ type: 'pre-fill' })
})
it('falls back to live HEAD when neither edit draft nor pre-fill provided', () => {
const seed = pickSeedSchema(undefined, undefined, { type: 'head' })
expect(seed).toEqual({ type: 'head' })
})
})