- NAMEGEN_USAGES: +disney, +pokemon, +encities, +hrcities, +usstates (jetzt 10 Einträge) - names.test.ts: Count-Test 5→10, neue toContain-Checks für alle 5 Codes Gate: vitest 107/107, e2e 160/160, tsc clean
79 lines
2.4 KiB
TypeScript
79 lines
2.4 KiB
TypeScript
/** FEAT-NAMEGEN: Tests für buildSuggestPath + NAMEGEN_USAGES. */
|
|
import { describe, expect, it } from 'vitest'
|
|
import { buildSuggestPath, NAMEGEN_USAGES } from '../names'
|
|
|
|
describe('buildSuggestPath', () => {
|
|
it('includes uppercased letter', () => {
|
|
const path = buildSuggestPath({ letter: 'f', gender: 'female', usages: ['norn'] })
|
|
expect(path).toContain('letter=F')
|
|
})
|
|
|
|
it('omits letter when blank', () => {
|
|
const path = buildSuggestPath({ letter: '', usages: ['norn'] })
|
|
expect(path).not.toContain('letter=')
|
|
})
|
|
|
|
it('omits letter when only whitespace', () => {
|
|
const path = buildSuggestPath({ letter: ' ', usages: ['norn'] })
|
|
expect(path).not.toContain('letter=')
|
|
})
|
|
|
|
it('includes gender', () => {
|
|
const path = buildSuggestPath({ gender: 'male', usages: ['norn'] })
|
|
expect(path).toContain('gender=male')
|
|
})
|
|
|
|
it('omits gender for empty string', () => {
|
|
const path = buildSuggestPath({ gender: '', usages: ['norn'] })
|
|
expect(path).not.toContain('gender=')
|
|
})
|
|
|
|
it('joins multiple usages without encoding commas', () => {
|
|
const path = buildSuggestPath({ usages: ['norn', 'mythg'] })
|
|
expect(path).toContain('usages=norn,mythg')
|
|
})
|
|
|
|
it('omits usages when array is empty', () => {
|
|
const path = buildSuggestPath({ usages: [] })
|
|
expect(path).not.toContain('usages=')
|
|
})
|
|
|
|
it('defaults count to 6', () => {
|
|
const path = buildSuggestPath({ usages: ['norn'] })
|
|
expect(path).toContain('count=6')
|
|
})
|
|
|
|
it('uses provided count', () => {
|
|
const path = buildSuggestPath({ usages: ['norn'], count: 8 })
|
|
expect(path).toContain('count=8')
|
|
})
|
|
|
|
it('starts with /names/suggest', () => {
|
|
const path = buildSuggestPath({ usages: ['norn'] })
|
|
expect(path).toMatch(/^\/names\/suggest\?/)
|
|
})
|
|
})
|
|
|
|
describe('NAMEGEN_USAGES', () => {
|
|
it('contains all 5 expected culture codes', () => {
|
|
const codes = NAMEGEN_USAGES.map((u) => u.code)
|
|
expect(codes).toContain('norn')
|
|
expect(codes).toContain('japa')
|
|
expect(codes).toContain('mythg')
|
|
expect(codes).toContain('ger')
|
|
expect(codes).toContain('arb')
|
|
expect(codes).toContain('disney')
|
|
expect(codes).toContain('pokemon')
|
|
expect(codes).toContain('encities')
|
|
expect(codes).toContain('hrcities')
|
|
expect(codes).toContain('usstates')
|
|
expect(codes).toHaveLength(10)
|
|
})
|
|
|
|
it('every usage has a non-empty label', () => {
|
|
for (const u of NAMEGEN_USAGES) {
|
|
expect(u.label.length).toBeGreaterThan(0)
|
|
}
|
|
})
|
|
})
|