From 2b934e4c6d83fafd418aa0f1940f31925ae63068 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Fri, 23 Oct 2026 20:16:59 +0200 Subject: companion: artist and groove lines Artist keys match as a case-insensitive substring of the MPRIS artist, so collaborations and feat. credits still hit; the cost is a short key over-matching, marked as a ponytail ceiling. appMap/appList take their defaults so the settings page can serve artists with the same helpers. Co-Authored-By: Claude Opus 5.5 --- desktop/companion/test_lines.js | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) (limited to 'desktop/companion/test_lines.js') diff --git a/desktop/companion/test_lines.js b/desktop/companion/test_lines.js index f70a9ff..72addf2 100644 --- a/desktop/companion/test_lines.js +++ b/desktop/companion/test_lines.js @@ -19,7 +19,7 @@ const assert = require("assert"); const src = fs.readFileSync(__dirname + "/Lines.js", "utf8") .replace(/^\.pragma library$/m, ""); const L = new Function(src + - "\nreturn { lines, apps, monologue, appMap, appList, pickApp, pick, toMap };")(); + "\nreturn { lines, apps, artists, monologue, appMap, appList, pickApp, pickArtist, pick, toMap };")(); // The defaults are what she says until a set is saved. assert.strictEqual(L.pickApp("firefox", null, 0), L.apps.firefox[0]); @@ -60,4 +60,20 @@ assert.deepStrictEqual(L.toMap([ { cls: "firefox", lines: ["last"] }, ]), { firefox: ["last"] }); +// Artists: a case-insensitive substring of what MPRIS reports, first +// matching key wins, empty phrases skipped. +assert.strictEqual(L.pickArtist("Linkin Park", null, 0), L.artists["linkin park"][0]); +assert.strictEqual(L.pickArtist("LINKIN PARK, Jay-Z", null, 0), L.artists["linkin park"][0]); +assert.strictEqual(L.pickArtist("Nobody", null, 0), ""); +assert.strictEqual(L.pickArtist("", null, 0), ""); +assert.strictEqual(L.pickArtist("Air, Beck", { air: ["a"], beck: ["b"] }, 0), "a"); +assert.strictEqual(L.pickArtist("Airbourne", { air: ["", "a"] }, 0), "a"); +assert.strictEqual(L.pick("artist:Eminem", 0, null, null), L.artists.eminem[0]); +assert.strictEqual(L.pick("artist:Eminem", 0, null, { eminem: ["mine"] }), "mine"); +assert.strictEqual(L.pick("groove", 0), L.lines.groove[0]); + +// The same list helpers serve the artist set. +assert.strictEqual(L.appMap(null, L.artists), L.artists); +assert.strictEqual(L.appList(null, L.artists).length, Object.keys(L.artists).length); +assert.deepStrictEqual(L.toMap(L.appList(null, L.artists)), L.artists); console.log("ok"); -- cgit v1.2.3