aboutsummaryrefslogtreecommitdiffstats
path: root/shared/test_notify_config.js
diff options
context:
space:
mode:
Diffstat (limited to 'shared/test_notify_config.js')
-rw-r--r--shared/test_notify_config.js18
1 files changed, 17 insertions, 1 deletions
diff --git a/shared/test_notify_config.js b/shared/test_notify_config.js
index b58fbde..c7bc2cc 100644
--- a/shared/test_notify_config.js
+++ b/shared/test_notify_config.js
@@ -18,7 +18,7 @@ const assert = require("assert");
const src = fs.readFileSync(__dirname + "/NotifyConfig.js", "utf8")
.replace(/^\.pragma library$/m, "");
-const C = new Function(src + "\nreturn { defaults, resolve, withheld };")();
+const C = new Function(src + "\nreturn { defaults, resolve, withheld, soundFor };")();
// Nothing, or garbage, is the defaults.
assert.deepStrictEqual(C.resolve(undefined), C.defaults());
@@ -48,4 +48,20 @@ assert.strictEqual(C.withheld(cfg, n("ok", "normal"), true), true);
assert.strictEqual(C.withheld(cfg, n("ok", "critical"), true), false);
assert.strictEqual(C.withheld(C.resolve({ dndPassCritical: false }), n("ok", "critical"), true), true);
+// Sounds: strings only, empty theme falls back.
+const s = C.resolve({ sounds: { low: "/a.oga", normal: 3 }, soundTheme: "" });
+assert.deepStrictEqual(s.sounds, { low: "/a.oga", normal: "", critical: "" });
+assert.strictEqual(s.soundTheme, "freedesktop");
+assert.strictEqual(C.resolve({ soundTheme: "mine" }).soundTheme, "mine");
+
+// soundFor: silent beats everything, the app's sound beats the urgency's.
+const sc = C.resolve({ sounds: { low: "", normal: "/n.oga", critical: "/c.oga" } });
+const sn = (urgency, sound, silent) => ({ app: "x", urgency, sound, silent });
+assert.strictEqual(C.soundFor(sc, sn("normal", "", false)), "/n.oga");
+assert.strictEqual(C.soundFor(sc, sn("low", "", false)), "");
+assert.strictEqual(C.soundFor(sc, sn("low", "/app.oga", false)), "/app.oga");
+assert.strictEqual(C.soundFor(sc, sn("critical", "/app.oga", true)), "");
+// An old daemon publishes neither field.
+assert.strictEqual(C.soundFor(sc, { app: "x", urgency: "critical" }), "/c.oga");
+
console.log("ok");