/*
* Famedly Matrix SDK
* Copyright (C) 2021 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:matrix/src/utils/html_to_text.dart';
import 'package:test/test.dart';
void main() {
group('htmlToText', () {
final testMap = {
'': '',
'hello world\nthis is a test': 'hello world\nthis is a test',
'That\'s not a test, this is a test':
'*That\'s* not a test, **this** is a test',
'Visit our website (outdated)':
'Visit ~~πour website~~ (outdated)',
'(cw spiders) spiders are pretty cool':
'(cw spiders) βββββββββββββββββββββββ',
'spiders are pretty cool':
'(cw spiders) βββββββββββββββββββββββ',
'': 'a test case',
'List of cute animals:\n\n- Kittens
\n- Puppies
\n- Snakes
(I think they\'re cute!) \n
\n(This list is incomplete, you can help by adding to it!)':
'List of cute animals:\nβ Kittens\nβ Puppies\nβ Snakes\n (I think they\'re cute!)\n(This list is incomplete, you can help by adding to it!)',
'fox': '*fox*',
'fox': '*fox*',
'fox': '**fox**',
'fox': '**fox**',
'fox': '__fox__',
'fox': '__fox__',
'fox': '~~fox~~',
'fox': '~~fox~~',
'fox': '~~fox~~',
'>fox
': '`>fox`',
'meep
': '```\nmeep\n```',
'meep\n
': '```\nmeep\n```',
'meep
':
'```floof\nmeep\n```',
'beforecode
after': 'before\n```\ncode\n```\nafter',
'before
code
after
':
'before\n```\ncode\n```\nafter',
'fox
': 'fox',
'fox
floof
': 'fox\n\nfloof',
'website': 'πwebsite',
'fox': 'fox',
'fox': 'fox',
'': ':wave:',
'fox
floof': 'fox\nfloof',
'fox
floof': '> fox\nfloof',
'fox
floof': '> fox\nfloof',
'fox
floof
': '> fox\nfloof',
'afox
floof': 'a\n> fox\nfloof',
'fox
floof
fluff':
'> > fox\n> floof\nfluff',
'':
'β hey\n β a\n β b\nβ foxies',
'- a
- b
': '1. a\n2. b',
'- a
- b
': '42. a\n43. b',
'- a
- aa
- bb
- b
':
'1. a\n 1. aa\n 2. bb\n2. b',
'- a
- b
':
'1. a\n β aa\n β bb\n2. b',
'':
'β a\n 1. aa\n 2. bb\nβ b',
'bunnyfox': 'fox',
'fox
floof': 'fox\n----------\nfloof',
'fox
floof
': 'fox\n----------\nfloof',
'fox
floof': '# fox\nfloof',
'fox
floof
': '# fox\nfloof',
'flooffox
': 'floof\n# fox',
'floof
fox
': 'floof\n# fox',
'fox
': '## fox',
'fox
': '### fox',
'fox
': '#### fox',
'fox
': '##### fox',
'fox
': '###### fox',
'fox': 'fox',
'fox
\nfloof
': 'fox\n\nfloof',
'beepfox
\nfloof
': 'fox\n\nfloof',
'
': '``````',
};
for (final entry in testMap.entries) {
test(entry.key, () async {
expect(HtmlToText.convert(entry.key), entry.value);
});
}
});
}