mirror of
https://github.com/tiennm99/miti99bot.git
synced 2026-10-05 08:14:45 +00:00
56 lines
1.6 KiB
JavaScript
56 lines
1.6 KiB
JavaScript
import {mkdir, writeFile} from 'node:fs/promises';
|
|
import path from 'node:path';
|
|
import {renderWheelGif} from '../src/render/render-gif.js';
|
|
|
|
const smoke = process.argv.includes('--smoke');
|
|
const fixturesDir = path.join(process.cwd(), 'fixtures');
|
|
|
|
/** @type {{name: string, request: import('../src/schemas/wheel-request.js').WheelRenderRequest}[]} */
|
|
const fixtures = [
|
|
{
|
|
name: 'smoke',
|
|
request: {
|
|
options: ['alpha', 'beta', 'gamma', 'delta'],
|
|
winnerIndex: 1,
|
|
durationMs: smoke ? 3000 : 6500,
|
|
holdMs: smoke ? 500 : 1200,
|
|
fps: 12,
|
|
size: smoke ? 384 : 512,
|
|
theme: 'classic',
|
|
},
|
|
},
|
|
{
|
|
name: 'vietnamese',
|
|
request: {
|
|
options: ['khong dau', 'co dau', 'banh mi', 'ca phe sua da', 'pho bo', 'goi cuon', 'ha noi', 'sai gon'],
|
|
winnerIndex: 3,
|
|
durationMs: 6500,
|
|
holdMs: 1200,
|
|
fps: 15,
|
|
size: 512,
|
|
theme: 'festival',
|
|
},
|
|
},
|
|
{
|
|
name: 'sixteen-options',
|
|
request: {
|
|
options: Array.from({length: 16}, (_, index) => `option ${index + 1}`),
|
|
winnerIndex: 9,
|
|
durationMs: 6500,
|
|
holdMs: 1200,
|
|
fps: 15,
|
|
size: 512,
|
|
theme: 'classic',
|
|
},
|
|
},
|
|
];
|
|
|
|
await mkdir(fixturesDir, {recursive: true});
|
|
|
|
for (const fixture of smoke ? fixtures.slice(0, 1) : fixtures) {
|
|
const result = await renderWheelGif(fixture.request, {timeoutInMilliseconds: 30000});
|
|
const output = path.join(fixturesDir, `${fixture.name}.gif`);
|
|
await writeFile(output, result.buffer);
|
|
console.log(`${fixture.name}: ${output} ${result.byteLength} bytes ${result.durationMs}ms`);
|
|
}
|