源码快照 @ 2026-09-02 (source-only, 剔除非源码素材)
This commit is contained in:
commit
04bac1f6e2
2200 files changed
+489415
No files matched your search
@@ -0,0 +1,44 @@
|
||||
import assert from "node:assert/strict";
|
||||
import test from "node:test";
|
||||
|
||||
import { resetMacDockIcon } from "./brand-icon-darwin.mjs";
|
||||
|
||||
function fakeDock() {
|
||||
const calls = [];
|
||||
return {
|
||||
calls,
|
||||
setIcon(image) {
|
||||
calls.push(image);
|
||||
},
|
||||
};
|
||||
}
|
||||
|
||||
test("re-applies the loose default icon when one exists (dev builds)", () => {
|
||||
const dock = fakeDock();
|
||||
const image = { isEmpty: () => false };
|
||||
|
||||
assert.deepEqual(resetMacDockIcon(dock, image), { ok: true });
|
||||
assert.deepEqual(dock.calls, [image]);
|
||||
});
|
||||
|
||||
test("restores the bundle icon via setIcon(null) when no loose default icon ships (packaged builds)", () => {
|
||||
const dock = fakeDock();
|
||||
|
||||
assert.deepEqual(resetMacDockIcon(dock, null), { ok: true });
|
||||
assert.deepEqual(dock.calls, [null]);
|
||||
});
|
||||
|
||||
test("treats an empty default image like a missing one", () => {
|
||||
const dock = fakeDock();
|
||||
|
||||
assert.deepEqual(resetMacDockIcon(dock, { isEmpty: () => true }), { ok: true });
|
||||
assert.deepEqual(dock.calls, [null]);
|
||||
});
|
||||
|
||||
test("reports when the dock is unavailable instead of throwing", () => {
|
||||
assert.deepEqual(resetMacDockIcon(null, null), { ok: false, reason: "dock-unavailable" });
|
||||
assert.deepEqual(resetMacDockIcon(undefined, { isEmpty: () => false }), {
|
||||
ok: false,
|
||||
reason: "dock-unavailable",
|
||||
});
|
||||
});
|
||||
Reference in new issue
Block a user