forked from eatvio/eatvio_app
feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing
This commit is contained in:
69
test/features/feed/models/comment_model_test.dart
Normal file
69
test/features/feed/models/comment_model_test.dart
Normal file
@@ -0,0 +1,69 @@
|
||||
import 'package:eatvio_app/core/models/pagination_model.dart';
|
||||
import 'package:eatvio_app/features/feed/models/comment_model.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
|
||||
void main() {
|
||||
group('CommentModel', () {
|
||||
test('создает CommentModel с правильными значениями', () {
|
||||
final comment = Comment(
|
||||
id: 1,
|
||||
authorName: 'Author Name',
|
||||
authorSlug: 'author',
|
||||
authorProfileIcon: 'https://example.com/icon.jpg',
|
||||
body: 'Test comment',
|
||||
childrenComments: [],
|
||||
createdAt: DateTime(2024, 1, 1),
|
||||
);
|
||||
|
||||
final model = CommentModel(
|
||||
data: [comment],
|
||||
links: const Links(
|
||||
first: 'https://example.com?page=1',
|
||||
last: 'https://example.com?page=1',
|
||||
prev: null,
|
||||
next: null,
|
||||
),
|
||||
meta: const Meta(
|
||||
currentPage: 1,
|
||||
from: 1,
|
||||
lastPage: 1,
|
||||
links: [],
|
||||
perPage: 10,
|
||||
to: 1,
|
||||
total: 1,
|
||||
),
|
||||
);
|
||||
|
||||
expect(model.data.length, 1);
|
||||
expect(model.data.first.id, 1);
|
||||
expect(model.data.first.body, 'Test comment');
|
||||
});
|
||||
});
|
||||
|
||||
group('Comment', () {
|
||||
test('создает Comment с вложенными комментариями', () {
|
||||
final childComment = Comment(
|
||||
id: 2,
|
||||
authorName: 'Child Author',
|
||||
authorSlug: 'child-author',
|
||||
authorProfileIcon: 'https://example.com/icon2.jpg',
|
||||
body: 'Child comment',
|
||||
childrenComments: [],
|
||||
createdAt: DateTime(2024, 1, 2),
|
||||
);
|
||||
|
||||
final parentComment = Comment(
|
||||
id: 1,
|
||||
authorName: 'Author Name',
|
||||
authorSlug: 'author',
|
||||
authorProfileIcon: 'https://example.com/icon.jpg',
|
||||
body: 'Parent comment',
|
||||
childrenComments: [childComment],
|
||||
createdAt: DateTime(2024, 1, 1),
|
||||
);
|
||||
|
||||
expect(parentComment.childrenComments.length, 1);
|
||||
expect(parentComment.childrenComments.first.id, 2);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user