diff --git a/src/helpers/dockPolicy.js b/src/helpers/dockPolicy.js index 7a3702de6..af87417e4 100644 --- a/src/helpers/dockPolicy.js +++ b/src/helpers/dockPolicy.js @@ -10,7 +10,8 @@ // Whether the Dock icon should be visible right now. // Returns null off macOS, where there is no Dock to act on. -export function resolveDockVisibility({ platform, controlPanelVisible }) { +export function resolveDockVisibility(params = {}) { + const { platform, controlPanelVisible } = params || {}; if (platform !== "darwin") return null; return !!controlPanelVisible; } diff --git a/test/helpers/dockPolicy.test.js b/test/helpers/dockPolicy.test.js index 3b216f88c..cccdf6ec4 100644 --- a/test/helpers/dockPolicy.test.js +++ b/test/helpers/dockPolicy.test.js @@ -27,3 +27,12 @@ test("there is no Dock to act on outside macOS", async () => { assert.equal(resolveDockVisibility({ platform, controlPanelVisible: true }), null); } }); + +test("handles nullish and missing parameter safely", async () => { + const { resolveDockVisibility } = await load(); + + assert.equal(resolveDockVisibility(), null); + assert.equal(resolveDockVisibility(null), null); + assert.equal(resolveDockVisibility(undefined), null); + assert.equal(resolveDockVisibility({}), null); +});