worldmap-viewer

git clone https://git.godosa.eu/worldmap-viewer

master

raw ยท 728 bytes

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']);
});