20 lines
1.0 KiB
JavaScript
20 lines
1.0 KiB
JavaScript
import test from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { extractPanels, getComic } from '../src/services/comic.js';
|
|
|
|
test('extractPanels:从短剧分镜抽出每格【画面】,封顶6格', () => {
|
|
const juben = '第一场\n【场景】赤壁\n【画面】火船冲入曹军连船,烟焰漲天\n【台词】烧!\n第二场\n【画面】曹操登岸,败军北还\n';
|
|
const p = extractPanels(juben);
|
|
assert.deepEqual(p, ['火船冲入曹军连船,烟焰漲天', '曹操登岸,败军北还']);
|
|
// 超过6格封顶
|
|
const many = Array.from({ length: 9 }, (_, i) => `【画面】第${i}格`).join('\n');
|
|
assert.equal(extractPanels(many).length, 6);
|
|
// 无【画面】→空
|
|
assert.deepEqual(extractPanels('一首诗,没有分镜'), []);
|
|
});
|
|
|
|
test('getComic:默认关(无 INK_ART_ENABLED / 无 key)→ off,零网络零成本', async () => {
|
|
assert.deepEqual(await getComic(['一格画面']), { status: 'off' });
|
|
assert.deepEqual(await getComic([]), { status: 'off' });
|
|
});
|