Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/helpers/dockPolicy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
}
9 changes: 9 additions & 0 deletions test/helpers/dockPolicy.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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);
});
Loading