/
kochkatech
/
CorpGame
Обзор
Документация
Войти
/
kochkatech
/
CorpGame
Код
Запросы
1
Задачи
Вики
Пакеты
0
Релизы
1
CI/CD
Аналитика
dev
backend/src/interaction/interaction.calc.spec.ts
32 строки
1 KB
kochkareal
chore: добавлен .gitattributes, нормализованы переносы строк (LF везде, кроме .bat/.cmd)
06 авг 2026, 15:18
06 авг 2026, 15:18
c25ef1b
Код
Авторство
О чём код?
import { DEFAULT_GAME_CONFIG } from '../game/default-config'; import { buildTheftOptions, maxTransferAmount } from './interaction.calc'; describe('interaction.calc', () => { it('maxTransferAmount respects transferMaxPercent', () => { expect(maxTransferAmount(DEFAULT_GAME_CONFIG, 100)).toBe(50); expect(maxTransferAmount(DEFAULT_GAME_CONFIG, 33)).toBe(16); }); it('maxTransferAmount allows at least 1 when the resource exists (fixes 1-unit transfer)', () => { expect(maxTransferAmount(DEFAULT_GAME_CONFIG, 1)).toBe(1); expect(maxTransferAmount(DEFAULT_GAME_CONFIG, 2)).toBe(1); expect(maxTransferAmount(DEFAULT_GAME_CONFIG, 0)).toBe(0); }); it('buildTheftOptions always includes the real thief', () => { const options = buildTheftOptions('actor', ['team-a', 'team-b', 'team-c'], 3); expect(options).toContain('actor'); expect(options).toHaveLength(3); expect(new Set(options).size).toBe(3); }); it('buildTheftOptions caps at available teams when fewer than requested', () => { const options = buildTheftOptions('actor', ['team-a'], 3); expect(options.sort()).toEqual(['actor', 'team-a'].sort()); }); it('buildTheftOptions never duplicates the actor via filler pool', () => { const options = buildTheftOptions('actor', ['actor', 'team-a', 'team-b'], 3); expect(options.filter((id) => id === 'actor')).toHaveLength(1); }); });