mirror of
https://github.com/ZHANGTIANYAO1/teamspeak-music-bot.git
synced 2026-10-02 21:12:49 +08:00
feat(qq): include albums in search results
Add mapQqAlbums pure helper (exported, TDD-covered) and wire a parallel req_album sub-request (search_type: 8) into search(), populating the albums field of SearchResult. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
1 parent
a2453784c1
commit
7d9081efc1
2 files changed
+74
-6
No files matched your search
@@ -0,0 +1,43 @@
|
||||
import { describe, it, expect } from "vitest";
|
||||
import { mapQqAlbums } from "./qq.js";
|
||||
|
||||
describe("QQ adapter", () => {
|
||||
it("mapQqAlbums maps albumMID-style raw entries", () => {
|
||||
const raw = [
|
||||
{
|
||||
albumMID: "abc",
|
||||
albumName: "Aero",
|
||||
singerName: "Singer A",
|
||||
},
|
||||
{
|
||||
albumMID: "xyz",
|
||||
albumName: "Beta",
|
||||
singer: [{ name: "Singer B" }, { name: "Singer C" }],
|
||||
},
|
||||
];
|
||||
const out = mapQqAlbums(raw);
|
||||
expect(out).toHaveLength(2);
|
||||
expect(out[0]).toMatchObject({
|
||||
id: "abc",
|
||||
name: "Aero",
|
||||
artist: "Singer A",
|
||||
platform: "qq",
|
||||
});
|
||||
expect(out[0].coverUrl).toContain("T002R300x300M000abc.jpg");
|
||||
expect(out[1].artist).toBe("Singer B / Singer C");
|
||||
expect(out[1].coverUrl).toContain("xyz");
|
||||
});
|
||||
|
||||
it("mapQqAlbums returns [] for empty/null input", () => {
|
||||
expect(mapQqAlbums([])).toEqual([]);
|
||||
expect(mapQqAlbums(null as any)).toEqual([]);
|
||||
expect(mapQqAlbums(undefined as any)).toEqual([]);
|
||||
});
|
||||
|
||||
it("mapQqAlbums falls back to albumPic when no albumMID", () => {
|
||||
const raw = [{ albumName: "C", albumPic: "https://x/p.jpg", singerName: "S" }];
|
||||
const out = mapQqAlbums(raw);
|
||||
expect(out[0].coverUrl).toBe("https://x/p.jpg");
|
||||
expect(out[0].id).toBe("");
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user