- enough_mail: use uidFetchMessage/uidMarkSeen/uidMarkFlagged/uidMove/
uidMarkDeleted/uidExpunge, remove non-existent isUidSequence param,
fix SmtpClient construction and use quit() not disconnect()
- Drift: add @DataClassName('MailboxRow') to avoid ugly 'Mailboxe',
alias core model imports to resolve type name conflicts
- EmailsCompanion.insert: uid/receivedAt are required, not Value<T>
- Lint: remove unrecognised rules (prefer_const_collections,
avoid_returning_null_for_future), add missing mounted guards after await
- Tests: fix html_utils expectations to match trim() behaviour,
add explicit Map casts in email_model_test for avoid_dynamic_calls
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
70 lines
1.8 KiB
Dart
70 lines
1.8 KiB
Dart
import 'package:test/test.dart';
|
|
|
|
import 'package:sharedinbox/core/utils/html_utils.dart';
|
|
|
|
void main() {
|
|
group('htmlToPlain', () {
|
|
test('returns plain text unchanged', () {
|
|
expect(htmlToPlain('Hello world'), 'Hello world');
|
|
});
|
|
|
|
test('strips simple tags', () {
|
|
expect(htmlToPlain('<b>bold</b> text'), 'bold text');
|
|
});
|
|
|
|
test('converts <br> to newline', () {
|
|
expect(htmlToPlain('line1<br>line2'), 'line1\nline2');
|
|
});
|
|
|
|
test('converts self-closing <br/> to newline', () {
|
|
expect(htmlToPlain('line1<br/>line2'), 'line1\nline2');
|
|
});
|
|
|
|
test('converts <p> to newline', () {
|
|
expect(htmlToPlain('<p>paragraph</p>'), 'paragraph');
|
|
});
|
|
|
|
test('decodes &', () {
|
|
expect(htmlToPlain('a & b'), 'a & b');
|
|
});
|
|
|
|
test('decodes < and >', () {
|
|
expect(htmlToPlain('<tag>'), '<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('<div><p>text</p></div>'), 'text');
|
|
});
|
|
|
|
test('real-world HTML email snippet', () {
|
|
const html = '<p>Hello <b>Alice</b>,</p>'
|
|
'<p>Please find the invoice attached.</p>'
|
|
'<p>Best regards,<br/>Bob</p>';
|
|
final result = htmlToPlain(html);
|
|
expect(result, contains('Hello Alice,'));
|
|
expect(result, contains('Best regards,'));
|
|
expect(result, contains('Bob'));
|
|
});
|
|
});
|
|
}
|