Add Prettier and ESLint tooling (Refs #77)

This commit is contained in:
2026-10-09 15:56:13 -04:00
parent 8ed059b8d3
commit 16469e2d43
711 changed files with 99737 additions and 28286 deletions
+35 -13
View File
@@ -1,5 +1,10 @@
import { describe, expect, it } from 'vitest';
import { composeCfg, composeServerCfg, parseCfg, parseOverlay } from '../../src/lib/server/fleet/config-compose.js';
import {
composeCfg,
composeServerCfg,
parseCfg,
parseOverlay
} from '../../src/lib/server/fleet/config-compose.js';
import { T5_ZOMBIE_MAPS } from '../../src/lib/server/fleet/map-aliases.js';
const BASELINE = [
@@ -97,31 +102,48 @@ describe('automatic map selection', () => {
});
it('overrides legacy map-choice overlays while keeping other settings', () => {
const result = composeServerCfg(BASELINE, [{
id: 5, text: 'set sv_maprotation "map zombie_moon"\nset g_inactivity "0"'
}], 't5', 'zombie_cosmodrome');
const result = composeServerCfg(
BASELINE,
[
{
id: 5,
text: 'set sv_maprotation "map zombie_moon"\nset g_inactivity "0"'
}
],
't5',
'zombie_cosmodrome'
);
expect(result).toContain('set sv_maprotation "map zombie_cosmodrome"');
expect(result).not.toContain('map zombie_moon');
expect(result).toContain('set g_inactivity "0"');
});
it('appends the rotation when absent and preserves CRLF', () => {
expect(composeServerCfg('set sv_voice "1"\r\n', [], 't5', 'zombie_moon'))
.toBe('set sv_voice "1"\r\n// Map selected by Electric Cherry\r\nset sv_maprotation "map zombie_moon"\r\n');
expect(composeServerCfg('set sv_voice "1"\r\n', [], 't5', 'zombie_moon')).toBe(
'set sv_voice "1"\r\n// Map selected by Electric Cherry\r\nset sv_maprotation "map zombie_moon"\r\n'
);
});
it('removes conflicting duplicate assignments regardless of case or command form', () => {
const result = composeServerCfg([
'// keep this comment',
'set sv_maprotation "map zombie_theater"',
'seta SV_MAPROTATION "map zombie_moon"',
'sv_mapRotation "map zombie_pentagon"'
].join('\n'), [], 't5', 'zombie_cod5_sumpf');
const result = composeServerCfg(
[
'// keep this comment',
'set sv_maprotation "map zombie_theater"',
'seta SV_MAPROTATION "map zombie_moon"',
'sv_mapRotation "map zombie_pentagon"'
].join('\n'),
[],
't5',
'zombie_cod5_sumpf'
);
expect(result).toBe('// keep this comment\nset sv_maprotation "map zombie_cod5_sumpf"\n');
});
it.each([
[null, null], ['t5', null], ['t5', 'custom_map'], ['t6', 'zombie_theater']
[null, null],
['t5', null],
['t5', 'custom_map'],
['t6', 'zombie_theater']
])('preserves existing behavior for unsupported game/map %s/%s', (game, map) => {
expect(composeServerCfg(BASELINE, [], game, map)).toBe(composeCfg(BASELINE, []));
});