Files
pokemon-showdown-client/test/battle-log.test.js
Guangcong Luo b83967e980 Preact minor updates batch 48
- Fix parsing of bolded text in battles
- Fix teambuilder result issue
- Fix Register button
- Fix Pursuit activation message grouping
- Fix base species name in Teambuilder
- Fix build error
2026-09-11 22:22:14 -07:00

27 lines
1.2 KiB
JavaScript

const assert = require('assert').strict;
const fs = require('fs');
const path = require('path');
const vm = require('vm');
const {describe, it} = require('node:test');
const context = {window: {}, Config: {}};
vm.runInNewContext(fs.readFileSync(path.resolve(__dirname, '../play.pokemonshowdown.com/js/battle-log.js'), 'utf8'), context);
const {BattleLog} = context;
describe('BattleLog.parseLogMessage', () => {
it('formats each bold span independently', () => {
const expected = 'a <strong>foo</strong> b <strong>bar</strong> c';
assert.deepEqual(Array.from(BattleLog.parseLogMessage('a **foo** b **bar** c')), [expected, expected]);
});
it('escapes HTML inside and outside bold spans', () => {
const expected = '&lt;a&gt; <strong>&lt;foo&gt;</strong> &amp; <strong>bar</strong>';
assert.deepEqual(Array.from(BattleLog.parseLogMessage('<a> **<foo>** & **bar**')), [expected, expected]);
});
it('leaves unmatched markers literal and does not match across lines', () => {
const expected = '**foo<br />bar**<br /><strong>baz</strong> **unfinished';
assert.deepEqual(Array.from(BattleLog.parseLogMessage('**foo\nbar**\n**baz** **unfinished')), [expected, expected]);
});
});