feat(spotify): implement milestone M4 importers

This commit is contained in:
2026-04-12 02:00:50 -05:00
parent d8570edcf0
commit 141488c0f2
12 changed files with 521 additions and 14 deletions

View File

@@ -0,0 +1,33 @@
import assert from "node:assert/strict";
import { mkdtemp, writeFile } from "node:fs/promises";
import { join } from "node:path";
import { tmpdir } from "node:os";
import { test } from "node:test";
import { parseTextList, readTextList } from "../src/importers/text-list.js";
test("parses text list with comments, blanks, and dedupe", () => {
const refs = parseTextList(`
# favorites
Radiohead - Karma Police
Radiohead: Karma Police
// ignored
Massive Attack - Teardrop
`);
assert.equal(refs.some((ref) => ref.artist === "Radiohead" && ref.title === "Karma Police"), true);
assert.equal(refs.some((ref) => ref.artist === "Massive Attack" && ref.title === "Teardrop"), true);
assert.equal(refs.filter((ref) => ref.artist === "Radiohead" && ref.title === "Karma Police").length, 1);
});
test("reads text list from file", async () => {
const root = await mkdtemp(join(tmpdir(), "spotify-text-"));
const path = join(root, "tracks.txt");
await writeFile(path, "Radiohead - Karma Police\n");
const refs = await readTextList(path);
assert.equal(refs[0].artist, "Radiohead");
assert.equal(refs[0].title, "Karma Police");
});