53 lines
1.5 KiB
TypeScript
53 lines
1.5 KiB
TypeScript
import assert from 'node:assert/strict'
|
|
import {test} from 'node:test'
|
|
import {BANNERS, THEMES} from '../engine/core/cosmetics.ts'
|
|
import {
|
|
BANNER_OPTIONS,
|
|
DEFAULT_LOOK,
|
|
isWinterfest,
|
|
sanitizeLook,
|
|
THEME_OPTIONS,
|
|
} from './look.ts'
|
|
|
|
const none = {bestStreak: 0, totalStars: 0}
|
|
const lots = {bestStreak: 30, totalStars: 200}
|
|
|
|
test('nur Themen und Banner, die es in der Engine gibt', () => {
|
|
for (const t of THEME_OPTIONS) assert.ok(THEMES.includes(t.id), t.id)
|
|
for (const b of BANNER_OPTIONS) assert.ok(BANNERS.includes(b.id), b.id)
|
|
})
|
|
|
|
test('Gesperrtes und Unbekanntes fällt auf den Standard zurück', () => {
|
|
const wanted = {
|
|
color: 'cyan',
|
|
faction: 'orc',
|
|
theme: 'night',
|
|
banner: 'crown',
|
|
}
|
|
assert.deepEqual(sanitizeLook(wanted, none, '2026-11-20'), {
|
|
...DEFAULT_LOOK,
|
|
color: 'cyan',
|
|
})
|
|
assert.deepEqual(sanitizeLook(wanted, lots, '2026-11-20'), wanted)
|
|
assert.deepEqual(
|
|
sanitizeLook({theme: 'hack'}, lots, '2026-11-20'),
|
|
DEFAULT_LOOK,
|
|
)
|
|
assert.deepEqual(sanitizeLook(null, lots, '2026-11-20'), DEFAULT_LOOK)
|
|
})
|
|
|
|
test('Winterfest: 1. Dezember bis 6. Januar, auch während der Jury-Bewertung', () => {
|
|
assert.ok(isWinterfest('2026-12-01'))
|
|
assert.ok(isWinterfest('2026-12-16'))
|
|
assert.ok(isWinterfest('2027-01-06'))
|
|
assert.ok(!isWinterfest('2026-11-30'))
|
|
assert.ok(!isWinterfest('2027-01-07'))
|
|
assert.equal(
|
|
sanitizeLook({theme: 'winterfest'}, none, '2026-12-10').theme,
|
|
'winterfest',
|
|
)
|
|
assert.equal(
|
|
sanitizeLook({theme: 'winterfest'}, none, '2026-11-10').theme,
|
|
'classic',
|
|
)
|
|
})
|