cozy-games/packages/mnswpr/test/levels.test.js
Ayo 969ebba067 chore: restructure to new cozy-games monorepo
Reviewed-on: https://git.ayo.run/ayo/cozy-games/pulls/1
Co-authored-by: Ayo <ayo@ayco.io>
Co-committed-by: Ayo <ayo@ayco.io>
2026-07-03 13:53:13 +00:00

31 lines
964 B
JavaScript

import { describe, it, expect } from 'vitest'
import { levels } from '../levels.js'
describe('levels', () => {
it('defines the four expected difficulty presets', () => {
expect(Object.keys(levels)).toEqual([
'beginner',
'intermediate',
'expert',
'nightmare'
])
})
it('gives every level a well-formed, consistent shape', () => {
for (const [key, level] of Object.entries(levels)) {
expect(typeof level.rows).toBe('number')
expect(typeof level.cols).toBe('number')
expect(typeof level.mines).toBe('number')
expect(typeof level.name).toBe('string')
// the map key must match the level's own id, since lookups use both
expect(level.id).toBe(key)
}
})
it('never has more mines than there are cells', () => {
for (const level of Object.values(levels)) {
expect(level.mines).toBeLessThan(level.rows * level.cols)
expect(level.mines).toBeGreaterThan(0)
}
})
})