aboutsummaryrefslogtreecommitdiffstats
path: root/desktop/companion/test_lines.js
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-10-23 20:16:59 +0200
committerDanilo M. <danix@danix.xyz>2026-10-23 20:16:59 +0200
commit2b934e4c6d83fafd418aa0f1940f31925ae63068 (patch)
tree7db2fb9c7ca7f896f40588a33fe1aaea7ffe895a /desktop/companion/test_lines.js
parent17680b87de53605a53805a7326f2c1f4f92cc99a (diff)
downloadquickshell-2b934e4c6d83fafd418aa0f1940f31925ae63068.tar.gz
quickshell-2b934e4c6d83fafd418aa0f1940f31925ae63068.zip
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 <noreply@anthropic.com>
Diffstat (limited to 'desktop/companion/test_lines.js')
-rw-r--r--desktop/companion/test_lines.js18
1 files changed, 17 insertions, 1 deletions
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");