import 'package:flutter_test/flutter_test.dart'; import 'package:relatica/utils/html_to_edit_text_helper.dart'; void testConversion(String original, String expectedOutput) { final output = htmlToSimpleText(original); if (output != expectedOutput) { print(output); } expect(output, equals(expectedOutput)); } void main() { test('Empty conversion', () { const original = ''; const expected = ''; testConversion(original, expected); }); test('Plain text no p-tags', () { const original = 'This post is just text'; const expected = 'This post is just text'; testConversion(original, expected); }); test('Plain text with p-tags', () { const original = '

This post is just text

'; const expected = 'This post is just text\n'; testConversion(original, expected); }); test('Formatting tags', () { const original = '

Post with italics bold underlined

'; const expected = 'Post with *italics* **bold** underlined\n'; testConversion(original, expected); }); test('Embedded link', () { const original = "Add preview again
sdtimes.com/software-developme…"; const expected = ''' Add preview again https://sdtimes.com/software-development/eclipse-foundation-finds-significant-momentum-for-open-source-java-this-year/'''; testConversion(original, expected); }); test('Hashtags and mentions', () { const original = "Post with hashtags #linux and mentions @testuser2"; const expected = 'Post with hashtags #linux and mentions @testuser2@friendicadevtest1.myportal.social'; testConversion(original, expected); }); test('Hashtags within p-tags', () { const original = "

Indie requests boops.

#AcademicDogs

"; const expected = ''' Indie requests boops. #AcademicDogs '''; testConversion(original, expected); }); test('Hashtags, links, breaks, and p-tags with unicode', () { const original = "

North Dakota 🏴 COVID-19 current stats for Sat Mar 18 2023

Cases: 286,247
Deaths: 2,463
Recovered: 278,650
Active: 5,134
Tests: 2,462,480
Doses: 1,307,993

#covid_north_dakota
https://covid.yanoagenda.com/states/North%20Dakota

"; const expected = ''' North Dakota 🏴 COVID-19 current stats for Sat Mar 18 2023 Cases: 286,247 Deaths: 2,463 Recovered: 278,650 Active: 5,134 Tests: 2,462,480 Doses: 1,307,993 #covid_north_dakota https://covid.yanoagenda.com/states/North%20Dakota '''; testConversion(original, expected); }); // testPrint(bulletedListWithStuff); // final nestedList = // testPrint(nestedList); test('Simple bulleted list', () { const original = "

Hello

"; const expected = ''' Hello - bullet 1 - bullet 2'''; testConversion(original, expected); }); test('Heavily nested list', () { const original = "

List test

"; const expected = ''' List test - Level 1 a - Level 1 b - Level 2 a - Level 3 a - Level 3 b - Level 2 b'''; testConversion(original, expected); }); test('List with other HTML elements within', () { const original = "

Stuff in bulleted list

"; const expected = ''' Stuff in bulleted list - Text with *italics* **bold** underline - A hyperlink! https://kotlinlang.org/ - Hashtag #hashtag - Mention @testuser3@friendicadevtest1.myportal.social'''; testConversion(original, expected); }); }