/* * Ansible inventory script used at Famedly GmbH for managing many hosts * Copyright (C) 2019, 2020 Famedly GmbH * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero General Public License as * published by the Free Software Foundation, either version 3 of the * License, or (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU Affero General Public License for more details. * * You should have received a copy of the GNU Affero General Public License * along with this program. If not, see . */ import 'package:famedlysdk/src/utils/markdown.dart'; import 'package:test/test.dart'; void main() { group('markdown', () { final emotePacks = { 'room': { ':fox:': 'mxc://roomfox', ':bunny:': 'mxc://roombunny', }, 'user': { ':fox:': 'mxc://userfox', ':bunny:': 'mxc://userbunny', ':raccoon:': 'mxc://raccoon', }, }; test('simple markdown', () { expect(markdown('hey *there* how are **you** doing?'), 'hey there how are you doing?'); expect(markdown('wha ~~strike~~ works!'), 'wha strike works!'); }); test('spoilers', () { expect(markdown('Snape killed ||Dumbledoor||'), 'Snape killed Dumbledoor'); expect(markdown('Snape killed ||Story|Dumbledoor||'), 'Snape killed Dumbledoor'); }); test('multiple paragraphs', () { expect(markdown('Heya!\n\nBeep'), '

Heya!

\n

Beep

'); }); test('Other block elements', () { expect(markdown('# blah\n\nblubb'), '

blah

\n

blubb

'); }); test('linebreaks', () { expect(markdown('foxies\ncute'), 'foxies
\ncute'); }); test('emotes', () { expect(markdown(':fox:', emotePacks), ':fox:'); expect(markdown(':user~fox:', emotePacks), ':fox:'); expect(markdown(':raccoon:', emotePacks), ':raccoon:'); expect(markdown(':invalid:', emotePacks), ':invalid:'); expect(markdown(':room~invalid:', emotePacks), ':room~invalid:'); }); test('pills', () { expect(markdown('Hey @sorunome:sorunome.de!'), 'Hey @sorunome:sorunome.de!'); expect(markdown('#fox:sorunome.de: you all are awesome'), '#fox:sorunome.de: you all are awesome'); expect(markdown('!blah:example.org'), '!blah:example.org'); }); test('latex', () { expect(markdown('meep \$\\frac{2}{3}\$'), 'meep \\frac{2}{3}'); expect(markdown('meep \$hmm *yay*\$'), 'meep hmm *yay*'); expect(markdown('you have \$somevar and \$someothervar'), 'you have \$somevar and \$someothervar'); expect(markdown('meep ||\$\\frac{2}{3}\$||'), 'meep \\frac{2}{3}'); expect(markdown('meep `\$\\frac{2}{3}\$`'), 'meep \$\\frac{2}{3}\$'); expect(markdown('hey\n\$\$beep\$\$\nmeow'), '

hey

\n
\n
beep
\n
\n

meow

'); expect(markdown('hey\n\$\$\nbeep\nboop\n\$\$\nmeow'), '

hey

\n
\n
beep\nboop
\n
\n

meow

'); }); }); }