forked from eatvio/eatvio_app
96 lines
2.7 KiB
Dart
96 lines
2.7 KiB
Dart
import 'package:eatvio_app/core/models/pagination_model.dart';
|
||
import 'package:eatvio_app/features/feed/models/feed_consultant_model.dart';
|
||
import 'package:eatvio_app/features/profile/models/badge_model.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
void main() {
|
||
group('FeedConsultantModel', () {
|
||
test('создает FeedConsultantModel с правильными значениями', () {
|
||
const model = FeedConsultantModel(
|
||
slug: 'consultant-1',
|
||
name: 'Consultant Name',
|
||
description: 'Test description',
|
||
ratingPlace: 1,
|
||
totalScores: 450,
|
||
photo: 'https://example.com/photo.jpg',
|
||
badges: [
|
||
BadgeModel(
|
||
id: 1,
|
||
title: 'Badge 1',
|
||
description: 'Description',
|
||
image: 'https://example.com/badge1.jpg',
|
||
type: 'type',
|
||
),
|
||
],
|
||
);
|
||
|
||
expect(model.slug, 'consultant-1');
|
||
expect(model.name, 'Consultant Name');
|
||
expect(model.totalScores, 450);
|
||
expect(model.badges.length, 1);
|
||
});
|
||
|
||
test('fromJson создает FeedConsultantModel из JSON', () {
|
||
final json = {
|
||
'slug': 'consultant-1',
|
||
'name': 'Consultant Name',
|
||
'additional_info': 'Test description',
|
||
'rating_place': 1,
|
||
'total_scores': 450,
|
||
'profile_photo_url': 'https://example.com/photo.jpg',
|
||
'badges': [
|
||
{
|
||
'id': 1,
|
||
'title': 'Badge 1',
|
||
'description': 'Description',
|
||
'image': 'https://example.com/badge1.jpg',
|
||
'type': 'type'
|
||
},
|
||
],
|
||
};
|
||
|
||
final model = FeedConsultantModel.fromJson(json);
|
||
|
||
expect(model.slug, 'consultant-1');
|
||
expect(model.totalScores, 450);
|
||
});
|
||
});
|
||
|
||
group('FeedConsultantPaginationModel', () {
|
||
test('создает FeedConsultantPaginationModel с правильными значениями', () {
|
||
const consultant = FeedConsultantModel(
|
||
slug: 'consultant-1',
|
||
name: 'Consultant Name',
|
||
description: 'Test description',
|
||
ratingPlace: null,
|
||
totalScores: 450,
|
||
photo: 'https://example.com/photo.jpg',
|
||
badges: [],
|
||
);
|
||
|
||
const pagination = FeedConsultantPaginationModel(
|
||
data: [consultant],
|
||
links: Links(
|
||
first: 'https://example.com?page=1',
|
||
last: 'https://example.com?page=1',
|
||
prev: null,
|
||
next: null,
|
||
),
|
||
meta: Meta(
|
||
currentPage: 1,
|
||
from: 1,
|
||
lastPage: 1,
|
||
links: [],
|
||
perPage: 10,
|
||
to: 1,
|
||
total: 1,
|
||
),
|
||
);
|
||
|
||
expect(pagination.data.length, 1);
|
||
expect(pagination.data.first.slug, 'consultant-1');
|
||
});
|
||
});
|
||
}
|
||
|