Files
ashen-realms/apps/web/src/app/shared/monster-artwork.spec.ts
2026-08-23 12:02:20 +02:00

79 lines
2.6 KiB
TypeScript

import {
combatMonsterSpriteScale,
monsterCutoutPath,
monsterIconPath,
runtimeMonsterArtworkPath,
} from './monster-artwork';
describe('runtimeMonsterArtworkPath', () => {
it('returns the optimized JPEG derivative for a known monster artwork path', () => {
expect(runtimeMonsterArtworkPath('/images/monsters/ash-rat.png')).toBe(
'/images/monsters/runtime/ash-rat-560.jpg',
);
});
it('returns undefined for an artwork path with no runtime derivative', () => {
expect(runtimeMonsterArtworkPath('/images/enemies/Dawnwolf.png')).toBeUndefined();
});
});
describe('monsterCutoutPath', () => {
it('returns the background-free cut-out for a known monster key', () => {
expect(monsterCutoutPath('ash-rat')).toBe('/images/combat/sprites/ash-rat-760.png');
expect(monsterCutoutPath('road-bandit')).toBe('/images/combat/sprites/road-bandit-620.png');
expect(monsterCutoutPath('wild-road-dog')).toBe(
'/images/combat/sprites/wild-road-dog-760.png',
);
expect(monsterCutoutPath('charred-looter')).toBe(
'/images/combat/sprites/charred-looter-620.png',
);
});
it('returns undefined for a monster without a cut-out', () => {
expect(monsterCutoutPath('dawnwolf')).toBeUndefined();
});
});
describe('monsterIconPath', () => {
it('returns the medallion icon for a known monster key', () => {
expect(monsterIconPath('ash-rat')).toBe('/images/combat/icons/ash-rat-128.png');
expect(monsterIconPath('road-bandit')).toBe('/images/combat/icons/road-bandit-128.png');
expect(monsterIconPath('charred-looter')).toBe(
'/images/combat/icons/charred-looter-128.png',
);
});
it('returns undefined for a monster without an icon', () => {
expect(monsterIconPath('dawnwolf')).toBeUndefined();
});
});
describe('watchpost monsters', () => {
const keys = ['raider-scout', 'raider-veteran', 'burned-hound', 'raider-captain'];
it('has a cutout for every watchpost monster', () => {
for (const key of keys) {
expect(monsterCutoutPath(key)).toBeDefined();
}
});
it('has an icon for every watchpost monster', () => {
for (const key of keys) {
expect(monsterIconPath(key)).toBeDefined();
}
});
it('has a runtime derivative for every watchpost artwork', () => {
for (const key of keys) {
expect(runtimeMonsterArtworkPath(`/images/monsters/${key}.png`)).toBeDefined();
}
});
it('scales the captain larger than the hound', () => {
// A hulking elite and a low-slung dog must not share a silhouette height.
expect(combatMonsterSpriteScale('raider-captain')).toBeGreaterThan(
combatMonsterSpriteScale('burned-hound'),
);
});
});