forked from eatvio/eatvio_app
43 lines
1015 B
Dart
43 lines
1015 B
Dart
import 'package:eatvio_app/features/feed/models/view_model.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
void main() {
|
||
group('ViewModel', () {
|
||
test('создает ViewModel с правильными значениями', () {
|
||
final model = ViewModel(
|
||
type: 'blog_posts',
|
||
ids: [1, 2, 3],
|
||
slugs: null,
|
||
);
|
||
|
||
expect(model.type, 'blog_posts');
|
||
expect(model.ids, [1, 2, 3]);
|
||
expect(model.slugs, isNull);
|
||
});
|
||
|
||
test('создает ViewModel с slugs', () {
|
||
final model = ViewModel(
|
||
type: 'plans',
|
||
ids: null,
|
||
slugs: ['plan-1', 'plan-2'],
|
||
);
|
||
|
||
expect(model.type, 'plans');
|
||
expect(model.slugs, ['plan-1', 'plan-2']);
|
||
});
|
||
|
||
test('fromJson создает ViewModel из JSON', () {
|
||
final json = {
|
||
'type': 'diets',
|
||
'ids': [1, 2],
|
||
};
|
||
|
||
final model = ViewModel.fromJson(json);
|
||
|
||
expect(model.type, 'diets');
|
||
expect(model.ids, [1, 2]);
|
||
});
|
||
});
|
||
}
|
||
|