test(tests): add comprehensive unit tests for various models and repositories, enhancing test coverage and ensuring correct functionality

This commit is contained in:
mso7nueh
2025-12-09 16:19:48 +03:00
parent edd064d20d
commit 70e4a42e98
25 changed files with 2565 additions and 58 deletions

View File

@@ -52,5 +52,45 @@ void main() {
expect(model1 == model2, false);
});
test('fromJson - создает модель из JSON', () {
final json = {'body': 'Test comment body'};
final model = CommentUpdateModel.fromJson(json);
expect(model.body, 'Test comment body');
});
test('fromJson - обрабатывает пустую строку', () {
final json = {'body': ''};
final model = CommentUpdateModel.fromJson(json);
expect(model.body, '');
});
test('fromJson - обрабатывает длинный текст', () {
final longBody = 'A' * 1000;
final json = {'body': longBody};
final model = CommentUpdateModel.fromJson(json);
expect(model.body, longBody);
expect(model.body.length, 1000);
});
test('toJson - преобразует модель в JSON', () {
final model = CommentUpdateModel(body: 'Test comment body');
final json = model.toJson();
expect(json, isA<Map<String, dynamic>>());
expect(json['body'], 'Test comment body');
});
test('toJson и fromJson - обратное преобразование', () {
final originalModel = CommentUpdateModel(body: 'Test comment');
final json = originalModel.toJson();
final restoredModel = CommentUpdateModel.fromJson(json);
expect(restoredModel.body, originalModel.body);
expect(restoredModel, originalModel);
});
});
}