Files
tiennm99bot/renderer/test/gacha-request.test.js
T
tiennm99 dccd524f9d feat(gacha): fly into the rank emblem with a rainbow sunburst and twinkling sky
The meteor now flies in from the upper left and lands on the rank emblem,
so the impact burst becomes the badge reveal. The 5-star rainbow ring is
replaced by a rainbow sunburst of counter-rotating rays. Sky stars twinkle
with short bright flares and cross glints, and each roll draws a fresh
layout from a per-request seed that the route picks when the caller sends
none.
2026-10-01 14:43:46 +07:00

39 lines
1.3 KiB
JavaScript

import {describe, expect, test} from 'vitest';
import {parseGachaRequest} from '../src/schemas/gacha-request.js';
const limits = {maxOptionChars: 12};
describe('parseGachaRequest', () => {
test('trims the label and applies defaults', () => {
const request = parseGachaRequest({label: ' Pizza ', rarity: 5}, limits, () => 42);
expect(request).toEqual({label: 'Pizza', rarity: 5, fps: 24, width: 640, seed: 42});
});
test('keeps a caller-provided seed', () => {
expect(parseGachaRequest({label: 'Pizza', rarity: 5, seed: 9}, limits, () => 42).seed).toBe(9);
});
test('accepts the larger frame and fps', () => {
const request = parseGachaRequest({label: 'Pho', rarity: 4, fps: 30, width: 854}, limits, () => 1);
expect(request.fps).toBe(30);
expect(request.width).toBe(854);
});
test.each([
{label: 'Pizza', rarity: 2},
{label: 'Pizza', rarity: 6},
{label: 'Pizza'},
{label: ' ', rarity: 3},
{label: 'x'.repeat(13), rarity: 3},
{label: 'Pizza', rarity: 3, width: 512},
{label: 'Pizza', rarity: 3, fps: 15},
{label: 'Pizza', rarity: 3, extra: true},
{label: 'Pizza', rarity: 3, seed: -1},
{label: 'Pizza', rarity: 3, seed: 1.5},
])('rejects %o', (input) => {
expect(() => parseGachaRequest(input, limits, () => 0)).toThrow();
});
});