forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user