mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 13:02:49 +08:00
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
32 lines
999 B
TypeScript
32 lines
999 B
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { parseLyrics } from "./netease.js";
|
|
|
|
describe("NetEase adapter", () => {
|
|
it("parses LRC format lyrics", () => {
|
|
const lrc = `[00:00.00] 作词 : 周杰伦
|
|
[00:01.00] 作曲 : 周杰伦
|
|
[00:12.50]故事的小黄花
|
|
[00:15.80]从出生那年就飘着`;
|
|
|
|
const lines = parseLyrics(lrc);
|
|
expect(lines).toHaveLength(2);
|
|
expect(lines[0].time).toBeCloseTo(12.5, 1);
|
|
expect(lines[0].text).toBe("故事的小黄花");
|
|
expect(lines[1].time).toBeCloseTo(15.8, 1);
|
|
expect(lines[1].text).toBe("从出生那年就飘着");
|
|
});
|
|
|
|
it("handles empty lyrics", () => {
|
|
const lines = parseLyrics("");
|
|
expect(lines).toHaveLength(0);
|
|
});
|
|
|
|
it("merges translation lyrics", () => {
|
|
const lrc = "[00:12.50]Hello world";
|
|
const tlyric = "[00:12.50]你好世界";
|
|
const lines = parseLyrics(lrc, tlyric);
|
|
expect(lines[0].text).toBe("Hello world");
|
|
expect(lines[0].translation).toBe("你好世界");
|
|
});
|
|
});
|