feat(dependencies): add rxdart package and improve string extension methods for better handling of empty strings and gender parsing

This commit is contained in:
mso7nueh
2025-12-04 15:45:54 +03:00
parent 0cd8e662d9
commit 953230b387
100 changed files with 7202 additions and 14 deletions

View File

@@ -0,0 +1,155 @@
import 'package:eatvio_app/core/models/pagination_model.dart';
import 'package:flutter_test/flutter_test.dart';
void main() {
group('PaginationModel', () {
group('Links', () {
test('создает Links с правильными значениями', () {
const links = Links(
first: 'https://example.com?page=1',
last: 'https://example.com?page=10',
prev: null,
next: 'https://example.com?page=2',
);
expect(links.first, 'https://example.com?page=1');
expect(links.last, 'https://example.com?page=10');
expect(links.prev, isNull);
expect(links.next, 'https://example.com?page=2');
});
test('fromJson создает Links из JSON', () {
final json = {
'first': 'https://example.com?page=1',
'last': 'https://example.com?page=10',
'prev': null,
'next': 'https://example.com?page=2',
};
final links = Links.fromJson(json);
expect(links.first, 'https://example.com?page=1');
expect(links.last, 'https://example.com?page=10');
expect(links.prev, isNull);
expect(links.next, 'https://example.com?page=2');
});
});
group('Link', () {
test('создает Link с правильными значениями', () {
const link = Link(
url: 'https://example.com?page=2',
label: '2',
active: true,
);
expect(link.url, 'https://example.com?page=2');
expect(link.label, '2');
expect(link.active, isTrue);
});
test('создает Link с null значениями', () {
const link = Link(
url: null,
label: null,
active: null,
);
expect(link.url, isNull);
expect(link.label, isNull);
expect(link.active, isNull);
});
test('fromJson создает Link из JSON', () {
final json = {
'url': 'https://example.com?page=2',
'label': '2',
'active': true,
};
final link = Link.fromJson(json);
expect(link.url, 'https://example.com?page=2');
expect(link.label, '2');
expect(link.active, isTrue);
});
});
group('Meta', () {
test('создает Meta с правильными значениями', () {
const meta = Meta(
currentPage: 1,
from: 1,
lastPage: 10,
links: [],
path: 'https://example.com',
perPage: 20,
to: 20,
total: 200,
totalMinPrice: 100,
totalMaxPrice: 1000,
);
expect(meta.currentPage, 1);
expect(meta.from, 1);
expect(meta.lastPage, 10);
expect(meta.links, isEmpty);
expect(meta.path, 'https://example.com');
expect(meta.perPage, 20);
expect(meta.to, 20);
expect(meta.total, 200);
expect(meta.totalMinPrice, 100);
expect(meta.totalMaxPrice, 1000);
});
test('создает Meta с null значениями', () {
const meta = Meta(
currentPage: 1,
from: null,
lastPage: 1,
links: [],
path: null,
perPage: 20,
to: null,
total: 0,
totalMinPrice: null,
totalMaxPrice: null,
);
expect(meta.from, isNull);
expect(meta.path, isNull);
expect(meta.to, isNull);
expect(meta.totalMinPrice, isNull);
expect(meta.totalMaxPrice, isNull);
});
test('fromJson создает Meta из JSON', () {
final json = {
'current_page': 1,
'from': 1,
'last_page': 10,
'links': [],
'path': 'https://example.com',
'per_page': 20,
'to': 20,
'total': 200,
'total_min_price': 100,
'total_max_price': 1000,
};
final meta = Meta.fromJson(json);
expect(meta.currentPage, 1);
expect(meta.from, 1);
expect(meta.lastPage, 10);
expect(meta.path, 'https://example.com');
expect(meta.perPage, 20);
expect(meta.to, 20);
expect(meta.total, 200);
expect(meta.totalMinPrice, 100);
expect(meta.totalMaxPrice, 1000);
});
});
});
}