feat(tests): updated tests coverage to 66.5%

This commit is contained in:
misha
2026-01-14 18:47:11 +03:00
parent 497ff19cfa
commit 13ccf56df0
102 changed files with 10146 additions and 379 deletions

View File

@@ -43,6 +43,50 @@ void main() {
expect(model.mediaData, isNotNull);
expect(model.mediaData!.length, 1);
});
test('toJson serializes ChatMessageModel correctly', () {
final model = ChatMessageModel(
id: 1,
data: 'Test message',
mediaData: null,
authorId: 123,
updatedAt: DateTime(2024, 1, 1, 12, 0, 0),
isRead: false,
isCurrentUserAuthor: true,
roomId: 'room-1',
type: 'text',
);
final json = model.toJson();
expect(json['id'], 1);
expect(json['data'], 'Test message');
expect(json['author_id'], 123);
expect(json['read_by_to_user'], false);
expect(json['is_author_message_auth_user'], true);
expect(json['room_id'], 'room-1');
expect(json['type'], 'text');
});
test('toJson handles null fields correctly', () {
final model = ChatMessageModel(
id: 1,
data: 'Test message',
mediaData: null,
authorId: 123,
updatedAt: DateTime(2024, 1, 1, 12, 0, 0),
isRead: false,
isCurrentUserAuthor: null,
roomId: null,
type: null,
);
final json = model.toJson();
expect(json['is_author_message_auth_user'], isNull);
expect(json['room_id'], isNull);
expect(json['type'], isNull);
});
});
}