forked from eatvio/eatvio_app
feat(tests): updated tests coverage to 66.5%
This commit is contained in:
@@ -51,6 +51,46 @@ void main() {
|
||||
expect(model.users.sender.id, 1);
|
||||
expect(model.users.receiver.id, 2);
|
||||
});
|
||||
|
||||
test('toJson serializes ChatRoomModel correctly', () {
|
||||
const settings = ChatRoomSettingsModel(
|
||||
name: 'Room Name',
|
||||
state: 'active',
|
||||
);
|
||||
|
||||
const sender = ChatUserModel(
|
||||
id: 1,
|
||||
name: 'Sender',
|
||||
slug: 'sender',
|
||||
profilePhotoUrl: 'https://example.com/sender.jpg',
|
||||
);
|
||||
|
||||
const receiver = ChatUserModel(
|
||||
id: 2,
|
||||
name: 'Receiver',
|
||||
slug: 'receiver',
|
||||
profilePhotoUrl: 'https://example.com/receiver.jpg',
|
||||
);
|
||||
|
||||
const users = Users(sender: sender, receiver: receiver);
|
||||
|
||||
const model = ChatRoomModel(
|
||||
id: 'room-1',
|
||||
chatRoomSettings: settings,
|
||||
users: users,
|
||||
chosenPlanId: 1,
|
||||
chosenPlan: null,
|
||||
);
|
||||
|
||||
final json = model.toJson();
|
||||
|
||||
expect(json, isNotNull);
|
||||
expect(json, isA<Map<String, dynamic>>());
|
||||
expect(json['id'], 'room-1');
|
||||
expect(json['chosen_plan_id'], 1);
|
||||
expect(json.containsKey('chat_room_setting'), isTrue);
|
||||
expect(json.containsKey('users'), isTrue);
|
||||
});
|
||||
});
|
||||
|
||||
group('Users', () {
|
||||
@@ -63,6 +103,31 @@ void main() {
|
||||
expect(users.sender.id, 1);
|
||||
expect(users.receiver.id, 2);
|
||||
});
|
||||
|
||||
test('toJson serializes Users correctly', () {
|
||||
const sender = ChatUserModel(
|
||||
id: 1,
|
||||
name: 'Sender',
|
||||
slug: 'sender',
|
||||
profilePhotoUrl: 'https://example.com/sender.jpg',
|
||||
);
|
||||
|
||||
const receiver = ChatUserModel(
|
||||
id: 2,
|
||||
name: 'Receiver',
|
||||
slug: 'receiver',
|
||||
profilePhotoUrl: 'https://example.com/receiver.jpg',
|
||||
);
|
||||
|
||||
const users = Users(sender: sender, receiver: receiver);
|
||||
|
||||
final json = users.toJson();
|
||||
|
||||
expect(json, isNotNull);
|
||||
expect(json, isA<Map<String, dynamic>>());
|
||||
expect(json.containsKey('from_chat_user'), isTrue);
|
||||
expect(json.containsKey('to_chat_user'), isTrue);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user