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:
@@ -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')
|
||||
|
||||
Reference in New Issue
Block a user