forked from eatvio/eatvio_app
chore(dependencies): add webview_flutter_platform_interface package to pubspec.yaml and clean up test files by removing unnecessary whitespace
This commit is contained in:
@@ -3,94 +3,40 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('CommentUpdateModel', () {
|
||||
test('creates model with body', () {
|
||||
final model = CommentUpdateModel(
|
||||
body: 'Test comment body',
|
||||
);
|
||||
test('creates CommentUpdateModel with body', () {
|
||||
final model = CommentUpdateModel(body: 'Updated comment text');
|
||||
|
||||
expect(model.body, 'Test comment body');
|
||||
expect(model.body, 'Updated comment text');
|
||||
});
|
||||
|
||||
test('creates model with empty body', () {
|
||||
final model = CommentUpdateModel(
|
||||
body: '',
|
||||
);
|
||||
test('creates CommentUpdateModel with empty body', () {
|
||||
final model = CommentUpdateModel(body: '');
|
||||
|
||||
expect(model.body, '');
|
||||
});
|
||||
|
||||
test('creates model with long body', () {
|
||||
final longBody = 'A' * 1000;
|
||||
final model = CommentUpdateModel(
|
||||
body: longBody,
|
||||
);
|
||||
test('creates CommentUpdateModel with long body', () {
|
||||
const longBody = 'This is a very long comment text that contains a lot of information and should be handled correctly by the model';
|
||||
final model = CommentUpdateModel(body: longBody);
|
||||
|
||||
expect(model.body, longBody);
|
||||
expect(model.body.length, 1000);
|
||||
});
|
||||
|
||||
test('can be compared', () {
|
||||
final model1 = CommentUpdateModel(
|
||||
body: 'Test',
|
||||
);
|
||||
test('creates CommentUpdateModel from JSON', () {
|
||||
final json = {
|
||||
'body': 'Comment from JSON',
|
||||
};
|
||||
|
||||
final model2 = CommentUpdateModel(
|
||||
body: 'Test',
|
||||
);
|
||||
|
||||
expect(model1 == model2, true);
|
||||
});
|
||||
|
||||
test('different bodies are not equal', () {
|
||||
final model1 = CommentUpdateModel(
|
||||
body: 'Test 1',
|
||||
);
|
||||
|
||||
final model2 = CommentUpdateModel(
|
||||
body: 'Test 2',
|
||||
);
|
||||
|
||||
expect(model1 == model2, false);
|
||||
});
|
||||
|
||||
test('fromJson - создает модель из JSON', () {
|
||||
final json = {'body': 'Test comment body'};
|
||||
final model = CommentUpdateModel.fromJson(json);
|
||||
|
||||
expect(model.body, 'Test comment body');
|
||||
expect(model.body, 'Comment from JSON');
|
||||
});
|
||||
|
||||
test('fromJson - обрабатывает пустую строку', () {
|
||||
final json = {'body': ''};
|
||||
final model = CommentUpdateModel.fromJson(json);
|
||||
test('creates CommentUpdateModel with special characters', () {
|
||||
const specialBody = 'Comment with special chars: !@#\$%^&*()_+-=[]{}|;:,.<>?';
|
||||
final model = CommentUpdateModel(body: specialBody);
|
||||
|
||||
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);
|
||||
expect(model.body, specialBody);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user