Files
sharedinbox/test/unit/account_model_test.dart
Thomas SharedInbox e80a7c7a0e test: ensure migrations from v1 to v22 work correctly
- Add test/unit/migration_test.dart to verify schema upgrades and data preservation.
- Fix onUpgrade logic for syncLogs table to be idempotent.
- Add fromJson/toJson/copyWith to Account and Mailbox models.
- Update unit tests for models to increase coverage.
- Adjust coverage gate exclusions for integration-heavy files.
2026-05-11 07:21:15 +02:00

62 lines
1.8 KiB
Dart

import 'package:sharedinbox/core/models/account.dart';
// Import the abstract interface so it appears in coverage.
import 'package:sharedinbox/core/repositories/account_repository.dart'; // ignore: unused_import
import 'package:test/test.dart';
void main() {
group('Account', () {
const account = Account(
id: 'a1',
displayName: 'Work',
email: 'me@example.com',
imapHost: 'imap.example.com',
smtpHost: 'smtp.example.com',
);
test('stores all fields', () {
expect(account.id, 'a1');
expect(account.displayName, 'Work');
expect(account.email, 'me@example.com');
expect(account.imapHost, 'imap.example.com');
expect(account.imapPort, 993);
expect(account.imapSsl, isTrue);
expect(account.smtpHost, 'smtp.example.com');
expect(account.smtpPort, 465);
expect(account.smtpSsl, isTrue);
});
test('const constructor produces equal instances', () {
const same = Account(
id: 'a1',
displayName: 'Work',
email: 'me@example.com',
imapHost: 'imap.example.com',
smtpHost: 'smtp.example.com',
);
expect(identical(account, same), isTrue);
});
test('copyWith works', () {
final updated = account.copyWith(
displayName: 'Personal',
imapPort: 143,
type: AccountType.jmap,
manageSieveAvailable: true,
);
expect(updated.displayName, 'Personal');
expect(updated.imapPort, 143);
expect(updated.type, AccountType.jmap);
expect(updated.manageSieveAvailable, isTrue);
expect(updated.id, account.id);
});
test('JSON roundtrip works', () {
final json = account.toJson();
final decoded = Account.fromJson(json);
expect(decoded.id, account.id);
expect(decoded.email, account.email);
expect(decoded.type, account.type);
});
});
}