feat: 오픈 게임 취소와 유산 정산 경로 추가
별도 최고위험 권한으로 실행되는 원자적 취소 작업을 추가한다. 버려진 게임과 장수 기록의 보존·삭제 옵션, 오픈 원금 전액 환급 및 획득 포인트 보전율, 취소 상태와 관리자·과거기록 UI를 함께 반영한다.
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
import { describe, expect, it } from 'vitest';
|
||||
|
||||
import { calculateCancelledInheritancePoint } from '../src/scenario/gameCancellation.js';
|
||||
|
||||
describe('cancelled game inheritance settlement', () => {
|
||||
it('refunds every spent point and discards earned points at zero percent', () => {
|
||||
expect(
|
||||
calculateCancelledInheritancePoint({
|
||||
openingPoint: 10_000,
|
||||
earnedPoint: 2_345.75,
|
||||
earnedPointRetentionPercent: 0,
|
||||
})
|
||||
).toEqual({ retainedEarnedPoint: 0, finalPoint: 10_000 });
|
||||
});
|
||||
|
||||
it('retains the selected integer percentage without rounding upward', () => {
|
||||
expect(
|
||||
calculateCancelledInheritancePoint({
|
||||
openingPoint: 10_000,
|
||||
earnedPoint: 333,
|
||||
earnedPointRetentionPercent: 50,
|
||||
})
|
||||
).toEqual({ retainedEarnedPoint: 166, finalPoint: 10_166 });
|
||||
});
|
||||
|
||||
it('retains all earned points at one hundred percent', () => {
|
||||
expect(
|
||||
calculateCancelledInheritancePoint({
|
||||
openingPoint: 10_000,
|
||||
earnedPoint: 333,
|
||||
earnedPointRetentionPercent: 100,
|
||||
})
|
||||
).toEqual({ retainedEarnedPoint: 333, finalPoint: 10_333 });
|
||||
});
|
||||
|
||||
it.each([-1, 1.5, 101])('rejects invalid retention percentage %s', (earnedPointRetentionPercent) => {
|
||||
expect(() =>
|
||||
calculateCancelledInheritancePoint({
|
||||
openingPoint: 0,
|
||||
earnedPoint: 0,
|
||||
earnedPointRetentionPercent,
|
||||
})
|
||||
).toThrow('integer from 0 to 100');
|
||||
});
|
||||
});
|
||||
Reference in New Issue
Block a user