/* * 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': 'a test case', 'List of cute animals:\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```', 'before
code
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:': ':wave:', 'fox
floof': 'fox\nfloof', '
fox
floof': '> fox\nfloof', '

fox

floof': '> fox\nfloof', '

fox

floof

': '> fox\nfloof', 'a
fox
floof': 'a\n> fox\nfloof', '
fox
floof
fluff': '> > fox\n> floof\nfluff', '
  • hey
    • a
    • b
  • foxies
': '● hey\n β—‹ a\n β—‹ b\n● foxies', '
  1. a
  2. b
': '1. a\n2. b', '
  1. a
  2. b
': '42. a\n43. b', '
  1. a
    1. aa
    2. bb
  2. b
': '1. a\n 1. aa\n 2. bb\n2. b', '
  1. a
    • aa
    • bb
  2. b
': '1. a\n β—‹ aa\n β—‹ bb\n2. b', '
  • a
    1. aa
    2. bb
  • 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', 'floof

fox

': 'floof\n# fox', '

floof

fox

': 'floof\n# fox', '

fox

': '## fox', '

fox

': '### fox', '

fox

': '#### fox', '
fox
': '##### fox', '
fox
': '###### fox', 'fox': 'fox', '

fox

\n

floof

': 'fox\n\nfloof', 'beep

fox

\n

floof

': 'fox\n\nfloof', '
': '``````', }; for (final entry in testMap.entries) { test(entry.key, () async { expect(HtmlToText.convert(entry.key), entry.value); }); } }); }