From 3443c1c65e9f1753e1e656b35d08416c1fa298f2 Mon Sep 17 00:00:00 2001 From: godosa Date: Wed, 7 Oct 2026 00:14:38 +0200 Subject: worldmap-viewer: initial public history --- viewer/tests/public.test.mjs | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 viewer/tests/public.test.mjs (limited to 'viewer/tests/public.test.mjs') diff --git a/viewer/tests/public.test.mjs b/viewer/tests/public.test.mjs new file mode 100644 index 0000000..04ded8c --- /dev/null +++ b/viewer/tests/public.test.mjs @@ -0,0 +1,18 @@ +import { test } from 'node:test'; +import assert from 'node:assert/strict'; + +const { hiddenTabs, hideTabs } = await import('../js/public.js'); + +test('a read-only map hides the editing tabs; a private one hides none', () => { + assert.deepEqual(hiddenTabs({ read_only: true }), ['pins', 'regions', 'export']); + assert.deepEqual(hiddenTabs({ read_only: false }), []); + assert.deepEqual(hiddenTabs({}), []); + assert.deepEqual(hiddenTabs(null), []); +}); + +test('hideTabs removes the buttons and sections it names', () => { + const removed = []; + const doc = { querySelector: sel => ({ remove: () => removed.push(sel) }) }; + hideTabs(doc, ['pins']); + assert.deepEqual(removed, ['#panel nav [data-tab="pins"]', '#tab-pins']); +}); -- cgit