Skip to content

Commit 3b59a0d

Browse files
committed
test: regex word-boundary for trim assertion (coderabbit minor)
1 parent ee7bf36 commit 3b59a0d

1 file changed

Lines changed: 6 additions & 1 deletion

File tree

tests/cli/server-app.test.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1457,7 +1457,12 @@ test('eventBuffer is bounded by PARACOSM_EVENT_BUFFER_MAX (FIFO drop on overflow
14571457
// Asserting on turn 49 (the very last broadcast) confirms FIFO
14581458
// direction: oldest dropped, newest kept.
14591459
assert.ok(buf.includes('"turn":49'), `last-broadcast event missing from replay\nbuf head: ${buf.slice(0, 400)}`);
1460-
assert.ok(!buf.includes('"turn":0,'), `oldest event should have been trimmed\nbuf head: ${buf.slice(0, 400)}`);
1460+
// Regex with a word-boundary so we match "turn":0 regardless of
1461+
// what follows ("turn":0,, "turn":0}, "turn":0\n) while still
1462+
// rejecting "turn":0 as a prefix of larger numbers (e.g. "turn":01
1463+
// would never match — JSON.stringify of integers has no leading
1464+
// zeros, but the boundary keeps the assertion robust).
1465+
assert.ok(!/\"turn\":0\b/.test(buf), `oldest event should have been trimmed\nbuf head: ${buf.slice(0, 400)}`);
14611466
} finally {
14621467
server.close();
14631468
await once(server, 'close');

0 commit comments

Comments
 (0)