web/website/tests/realm-switch.test.mjs

3 lines
1.2 KiB
JavaScript

import test from 'node:test';import assert from 'node:assert/strict';import {realmSurface,withRealmSwitch} from '../scripts/realm-switch.mjs';import {MAIN_MENU} from '../scripts/main-menu.mjs';
test('realm switches are limited to the three organisation surfaces, never Boards or other public pages',()=>{for(const [url,expected]of [['https://clans.dunerealms.com/','clan'],['https://corp.dunerealms.com/','company'],['https://www.dunerealms.com/government.html','politics'],['https://forums.dunerealms.com/',null],['https://www.dunerealms.com/',null],['https://www.dunerealms.com/exchange.html',null],['https://support.dunerealms.com/',null],['https://www.dunerealms.com/realm-hub.html',null]])assert.equal(realmSurface(url),expected);const script=withRealmSwitch(withRealmSwitch('base'));assert.equal(script.split('/* Dune realm switch begin */').length,2);});
test('the canonical header uses the agreed names and keeps links for non-roleplay services',()=>{assert.deepEqual(MAIN_MENU.map(([name])=>name),['Home','Shop','Imperial Forums','Guild Comms','Imperial Directorate','Starport','Realm Nexus','Citizen Passport','Support','Imperial Archives']);assert.equal(MAIN_MENU.find(([name])=>name==='Shop')[1],'https://shop.dunerealms.com/');});