import 'package:sharedinbox/core/utils/html_utils.dart'; import 'package:test/test.dart'; void main() { group('htmlToPlain', () { test('returns plain text unchanged', () { expect(htmlToPlain('Hello world'), 'Hello world'); }); test('strips simple tags', () { expect(htmlToPlain('bold text'), 'bold text'); }); test('converts
to newline', () { expect(htmlToPlain('line1
line2'), 'line1\nline2'); }); test('converts self-closing
to newline', () { expect(htmlToPlain('line1
line2'), 'line1\nline2'); }); test('converts

to newline', () { expect(htmlToPlain('

paragraph

'), 'paragraph'); }); test('decodes &', () { expect(htmlToPlain('a & b'), 'a & b'); }); test('decodes < and >', () { expect(htmlToPlain('<tag>'), ''); }); test('decodes "', () { expect(htmlToPlain('say "hi"'), 'say "hi"'); }); test('decodes '', () { expect(htmlToPlain('it's'), "it's"); }); test('decodes   as space', () { expect(htmlToPlain('a b'), 'a b'); }); test('trims surrounding whitespace', () { expect(htmlToPlain(' hello '), 'hello'); }); test('handles empty string', () { expect(htmlToPlain(''), ''); }); test('handles nested tags', () { expect(htmlToPlain('

text

'), 'text'); }); test('real-world HTML email snippet', () { const html = '

Hello Alice,

' '

Please find the invoice attached.

' '

Best regards,
Bob

'; final result = htmlToPlain(html); expect(result, contains('Hello Alice,')); expect(result, contains('Best regards,')); expect(result, contains('Bob')); }); }); }