diablo2-web/tests/monster-art.test.ts

28 lines
1.1 KiB
TypeScript

import { describe, it, expect } from 'vitest'
import { MONSTER_COMPONENTS, findMonsterLayerSprite } from '../src/game/monster-art.ts'
describe('monster-art', () => {
it('covers all 16 monster composite component folders', () => {
expect(MONSTER_COMPONENTS.length).toBe(16)
expect(MONSTER_COMPONENTS[0]).toBe('hd')
expect(MONSTER_COMPONENTS[1]).toBe('tr')
expect(MONSTER_COMPONENTS[8]).toBe('s1')
expect(MONSTER_COMPONENTS[15]).toBe('s8')
})
it('finds monster layer sprites by convention', () => {
const names = [
'data\\global\\monsters\\fa\\tr\\fatrlitwlhth.dcc',
'data\\global\\monsters\\fa\\s1\\fas1litwlhth.dcc',
'data\\global\\monsters\\fa\\rh\\farhaxewlhth.dcc',
'data\\global\\monsters\\fa\\sh\\fashbucwlhth.dcc',
]
const root = 'data\\global\\monsters\\fa\\'
const hit = findMonsterLayerSprite(names, root, 'fa', 'wl', 'hth', 'tr')
expect(hit).toBe('data\\global\\monsters\\fa\\tr\\fatrlitwlhth.dcc')
const missing = findMonsterLayerSprite(names, root, 'fa', 'wl', 'hth', 'hd')
expect(missing).toBeUndefined()
})
})