aboutsummaryrefslogtreecommitdiffziptar.gz
path: root/viewer/tests/public.test.mjs
diff options
context:
space:
mode:
Diffstat (limited to 'viewer/tests/public.test.mjs')
-rw-r--r--viewer/tests/public.test.mjs18
1 files changed, 18 insertions, 0 deletions
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']);
+});