Lade Bilder aus E-Mails auf Wunsch über den Server nach und verkleinere den Kopf der Leseansicht auf dem Handy.
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
075525ee17
commit
a3f328832e
11 files changed
+365
-11
No files matched your search
@@ -0,0 +1,28 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
import { IMAGE_KEYS, deviceClass, readImageChoice, writeImageChoice } from "./mail-images.js";
|
||||
|
||||
function memory() {
|
||||
const data = {};
|
||||
return { getItem: (key) => (key in data ? data[key] : null), setItem: (key, value) => { data[key] = value; } };
|
||||
}
|
||||
|
||||
test("pictures are asked for by default and the choice is kept per device kind", () => {
|
||||
const store = memory();
|
||||
assert.equal(readImageChoice("touch", store), "ask");
|
||||
assert.equal(writeImageChoice("desktop", "auto", store), "auto");
|
||||
assert.equal(readImageChoice("desktop", store), "auto");
|
||||
assert.equal(readImageChoice("touch", store), "ask");
|
||||
assert.equal(writeImageChoice("touch", "anything", store), "ask");
|
||||
assert.ok(IMAGE_KEYS.desktop !== IMAGE_KEYS.touch);
|
||||
});
|
||||
|
||||
test("a blocked store and a missing media query fall back to the safe choice", () => {
|
||||
const broken = { getItem() { throw new Error("blocked"); }, setItem() { throw new Error("blocked"); } };
|
||||
assert.equal(readImageChoice("desktop", broken), "ask");
|
||||
assert.equal(writeImageChoice("desktop", "auto", broken), "auto");
|
||||
assert.equal(readImageChoice("desktop", null), "ask");
|
||||
assert.equal(deviceClass(null), "desktop");
|
||||
assert.equal(deviceClass(function () { return { matches: true }; }), "touch");
|
||||
assert.equal(deviceClass(function () { throw new Error("x"); }), "desktop");
|
||||
});
|
||||
Reference in new issue
Block a user