2026-03-07 23:58:41 +00:00
|
|
|
import { describe, it, expect } from 'vitest'
|
|
|
|
|
import { ARENAS, pickArena, randomArena } from './arenas.js'
|
|
|
|
|
|
|
|
|
|
describe('ARENAS', () => {
|
2026-03-09 07:20:08 +00:00
|
|
|
it('has 40 arenas', () => {
|
|
|
|
|
expect(ARENAS.length).toBe(40)
|
2026-03-07 23:58:41 +00:00
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('all arenas have required fields', () => {
|
|
|
|
|
for (const arena of ARENAS) {
|
|
|
|
|
expect(arena.id).toBeTruthy()
|
|
|
|
|
expect(arena.name).toBeTruthy()
|
|
|
|
|
expect(arena.description).toBeTruthy()
|
|
|
|
|
expect(typeof arena.id).toBe('string')
|
|
|
|
|
expect(typeof arena.name).toBe('string')
|
|
|
|
|
expect(typeof arena.description).toBe('string')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('all arena IDs are unique', () => {
|
|
|
|
|
const ids = ARENAS.map(a => a.id)
|
|
|
|
|
expect(new Set(ids).size).toBe(ids.length)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('all arena names are unique', () => {
|
|
|
|
|
const names = ARENAS.map(a => a.name)
|
|
|
|
|
expect(new Set(names).size).toBe(names.length)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('arenas with modifier also have modifierDescription', () => {
|
|
|
|
|
for (const arena of ARENAS) {
|
|
|
|
|
if (arena.modifier) {
|
|
|
|
|
expect(arena.modifierDescription).toBeTruthy()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('arenas without modifier have null modifierDescription', () => {
|
|
|
|
|
for (const arena of ARENAS) {
|
|
|
|
|
if (!arena.modifier) {
|
|
|
|
|
expect(arena.modifierDescription).toBeNull()
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('known modifiers are present', () => {
|
|
|
|
|
const modifiers = ARENAS.map(a => a.modifier).filter(Boolean)
|
|
|
|
|
expect(modifiers).toContain('speed_2x')
|
|
|
|
|
expect(modifiers).toContain('roast_2x')
|
|
|
|
|
expect(modifiers).toContain('food_2x')
|
|
|
|
|
expect(modifiers).toContain('meme_2x')
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('pickArena', () => {
|
|
|
|
|
it('same choices return The Singularity', () => {
|
|
|
|
|
const arena = pickArena(5, 5)
|
|
|
|
|
expect(arena.id).toBe('the_singularity')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('different choices return a non-singularity arena', () => {
|
|
|
|
|
const arena = pickArena(3, 7)
|
|
|
|
|
expect(arena.id).not.toBe('the_singularity')
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('deterministic for same inputs', () => {
|
|
|
|
|
const a1 = pickArena(10, 20)
|
|
|
|
|
const a2 = pickArena(10, 20)
|
|
|
|
|
expect(a1.id).toBe(a2.id)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('different inputs give different arenas (most of the time)', () => {
|
|
|
|
|
const arenas = new Set<string>()
|
|
|
|
|
for (let i = 0; i < 50; i++) {
|
|
|
|
|
arenas.add(pickArena(i, i + 1).id)
|
|
|
|
|
}
|
|
|
|
|
expect(arenas.size).toBeGreaterThan(3)
|
|
|
|
|
})
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
describe('randomArena', () => {
|
|
|
|
|
it('never returns The Singularity', () => {
|
|
|
|
|
for (let i = 0; i < 50; i++) {
|
|
|
|
|
const arena = randomArena()
|
|
|
|
|
expect(arena.id).not.toBe('the_singularity')
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('returns variety', () => {
|
|
|
|
|
const arenas = new Set<string>()
|
|
|
|
|
for (let i = 0; i < 100; i++) {
|
|
|
|
|
arenas.add(randomArena().id)
|
|
|
|
|
}
|
|
|
|
|
expect(arenas.size).toBeGreaterThan(5)
|
|
|
|
|
})
|
|
|
|
|
|
|
|
|
|
it('returns valid arena objects', () => {
|
|
|
|
|
for (let i = 0; i < 20; i++) {
|
|
|
|
|
const arena = randomArena()
|
|
|
|
|
expect(arena.id).toBeTruthy()
|
|
|
|
|
expect(arena.name).toBeTruthy()
|
|
|
|
|
expect(arena.description).toBeTruthy()
|
|
|
|
|
}
|
|
|
|
|
})
|
|
|
|
|
})
|