Set up frontend test infrastructure

Install @testing-library/react, @testing-library/jest-dom,
@testing-library/user-event, and jsdom. Configure Vitest with globals,
jsdom environment, and a setup file importing jest-dom matchers. Add a
custom render helper wrapping components with QueryClientProvider and
MemoryRouter. Exclude e2e/ from vitest. Smoke test covers
formatEvolutionMethod.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-21 13:35:15 +01:00
parent ee5bf03f19
commit c80d7d0802
9 changed files with 948 additions and 13 deletions

View File

@@ -0,0 +1,51 @@
import { formatEvolutionMethod } from './formatEvolution'
const base = { minLevel: null, item: null, heldItem: null, condition: null }
describe('formatEvolutionMethod', () => {
it('formats level-up with a min level', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'level-up', minLevel: 16 })).toBe('Level 16')
})
it('formats level-up without a min level', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'level-up' })).toBe('Level up')
})
it('formats use-item trigger', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'use-item', item: 'fire-stone' })).toBe(
'Fire Stone'
)
})
it('formats trade trigger', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'trade' })).toBe('Trade')
})
it('formats unknown trigger by capitalizing words', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'shed-skin' })).toBe('Shed Skin')
})
it('appends held item', () => {
expect(formatEvolutionMethod({ ...base, trigger: 'trade', heldItem: 'metal-coat' })).toBe(
'Trade, holding Metal Coat'
)
})
it('appends condition', () => {
expect(
formatEvolutionMethod({ ...base, trigger: 'level-up', minLevel: 20, condition: 'at night' })
).toBe('Level 20, at night')
})
it('combines all parts', () => {
expect(
formatEvolutionMethod({
trigger: 'level-up',
minLevel: 25,
item: null,
heldItem: 'kings-rock',
condition: 'high friendship',
})
).toBe('Level 25, holding Kings Rock, high friendship')
})
})