import test from 'node:test'; import assert from 'node:assert/strict'; import {imperialRaidEnvironment} from '../node/imperial-raid-configuration.mjs'; test('activation owns exactly one flag and preserves unrelated private bytes and line endings',()=>{ for(const old of ['# private\r\nGAME_LINK_SECRET=keep exactly\r\nIMPERIAL_RAIDS_ENABLED=false\r\nPOSTBANK_ENABLED=true\r\n','GAME_LINK_SECRET=keep\n','GAME_LINK_SECRET=keep']){ const value=imperialRaidEnvironment(old);assert.equal(imperialRaidEnvironment(value),value);assert.ok(value.includes('IMPERIAL_RAIDS_ENABLED=true'));assert.equal(value.replace(/^IMPERIAL_RAIDS_ENABLED=true\r?\n?/m,''),old.replace(/^IMPERIAL_RAIDS_ENABLED=false\r?\n?/m,'')+(old.endsWith('\n')?'':'\n')); } assert.throws(()=>imperialRaidEnvironment('IMPERIAL_RAIDS_ENABLED=true\nexport IMPERIAL_RAIDS_ENABLED=false\n'),/Duplicate/); });