GEN-1: expose CATALOG seed view (Name/CanonicalGenotype/SortOrder) for DATA-2 + round-trip test

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
This commit is contained in:
2026-06-05 23:47:11 +02:00
parent 3cf6413fcc
commit 3629e89e87
3 changed files with 65 additions and 4 deletions

View File

@@ -17,7 +17,14 @@ import {
wildType,
} from '../genotype'
import { combineLocus } from '../punnett'
import { farbschlagFor, genotypeToFarbschlag, CATALOG_SIZE } from '../catalog'
import {
farbschlagFor,
genotypeToFarbschlag,
representativeGenotype,
BASE_COLORS,
CATALOG,
CATALOG_SIZE,
} from '../catalog'
import { breed } from '../breed'
import { GeneticsWarningCode } from '../warnings'
@@ -170,6 +177,22 @@ describe('Farbschlag catalog', () => {
expect(CATALOG_SIZE).toBe(18)
})
it('every catalog entry round-trips: its representative genotype maps back to its own name', () => {
// Guards the DB seed (DATA-2): a representative genotype that resolved to a
// DIFFERENT (earlier) variety would mean overlapping/mis-ordered patterns.
for (const entry of BASE_COLORS) {
expect(genotypeToFarbschlag(representativeGenotype(entry))).toBe(entry.name)
}
})
it('CATALOG seed view mirrors the ColorVariety table shape', () => {
expect(CATALOG).toHaveLength(CATALOG_SIZE)
expect(CATALOG[0]).toMatchObject({ name: 'Pink Eyed White (PEW)', sortOrder: 0 })
// Every row has a non-empty canonical genotype display string and unique name.
expect(new Set(CATALOG.map((c) => c.name)).size).toBe(CATALOG.length)
expect(CATALOG.every((c) => /^[A-Za-z?]+( [A-Za-z?]+){7}$/.test(c.canonicalGenotype))).toBe(true)
})
it('genotypeToFarbschlag (DATA-1 denormalization contract) returns the plain name', () => {
expect(genotypeToFarbschlag(wildType())).toBe('Agouti')
expect(genotypeToFarbschlag(fromDisplayString('aa CC DD EE GG pp spsp rere'))).toBe('Platin')