'use strict'; const assert = require('assert').strict; describe('Chat', () => { it('should run formatText correctly', () => { assert.equal( Chat.formatText(`hi **__bold italics__** ^^superscript^^ \\\\subscript\\\\ normal ~~strikethrough~~ bye`), `hi bold italics superscript subscript normal strikethrough bye` ); assert.equal( Chat.formatText(`__**reverse nesting**__`), `reverse nesting` ); assert.equal( Chat.formatText(`__**bad nesting__**`), `**bad nesting**` ); assert.equal( Chat.formatText(`spaced ** out ** no __also no __ ~~ also no~~ ok`), `spaced ** out ** no __also no __ ~~ also no~~ ok` ); assert.equal( Chat.formatText(`hi \`\` \` \`\` bye`), `hi \` bye` ); assert.equal( Chat.formatText(`hi \`\`inside __not__ formatted\`\` bye`), `hi inside __not__ formatted bye` ); assert.equal( Chat.formatText(`<> <>`), `«roomid-1-2-3» <<roomid_1_2_3>>` ); assert.equal( Chat.formatText(`hi __spoiler: bye__ hi again (parenthetical spoiler: bye again (or not!!!!)) that was fun`), `hi spoiler: bye hi again (parenthetical spoiler: bye again (or not!!!!)) that was fun` ); assert.equal( Chat.formatText(`hi __||bye||__ hi again (parenthetical ||bye again (or not!!!!)||) that was fun`), `hi bye hi again (parenthetical bye again (or not!!!!)) that was fun` ); assert.equal( Chat.formatText(`hi google.com/__a__ bye >w<`), `hi google.com/__a__ bye >w<` ); assert.equal( Chat.formatText(`(https://en.wikipedia.org/wiki/Pokémon_(video_game_series))`), `(https://en.wikipedia.org/wiki/Pokémon_(video_game_series))` ); assert.equal( Chat.formatText(`hi email@email.com bye >w<`), `hi email@email.com bye >w<` ); assert.equal( Chat.formatText(`hi email@email.example bye >w<`), `hi email@email.example bye >w<` ); assert.equal( Chat.formatText(`>greentext`), `>greentext` ); assert.equal( Chat.formatText(`>w< not greentext >also not greentext`), `>w< not greentext >also not greentext` ); assert.equal( Chat.formatText(`[[Google ]] >w<`), `Google <google.com> >w<` ); assert.equal( Chat.formatText(`[[Google ]] >w<`, true), `Google >w<` ); assert.equal( Chat.formatText(`[[wiki: Pokemon]] >w<`, true), `wiki: Pokemon >w<` ); assert.equal( Chat.formatText(`[[wiki: D&D D&D]] [[A>B A>B]] &`, true), `wiki: D&D D&amp;D A>B A&gt;B &amp;` ); assert.equal( Chat.formatText(`[[pokemon: Oshawott]] >w<`, true), ` >w<` ); assert.equal( Chat.formatText(`[[item: Beast ball]] >w<`), `[Beast ball] >w<` ); assert.equal( Chat.formatText(`:)`, true), `:)` ); assert.equal( Chat.formatText(`a\nb\nc`), `a\nb\nc` ); assert.equal( Chat.formatText(`a\nb\nc`, true), `a
b
c` ); assert.equal( Chat.formatText(`a\nb\nc`, false, true), `a
b
c` ); }); it('should run toDurationString correctly', () => { assert(Chat.toDurationString(1e50)); assert(!Chat.toDurationString(10000000 * 24 * 60 * 60 * 1000).includes(' ')); }); });