forked from eatvio/eatvio_app
66 lines
1.8 KiB
Dart
66 lines
1.8 KiB
Dart
import 'package:eatvio_app/features/create_recipe/models/step.dart';
|
||
import 'package:flutter_test/flutter_test.dart';
|
||
|
||
void main() {
|
||
group('Step', () {
|
||
test('создает Step с правильными значениями', () {
|
||
const step = Step(
|
||
image: 'https://example.com/image.jpg',
|
||
description: 'Test step description',
|
||
);
|
||
|
||
expect(step.image, 'https://example.com/image.jpg');
|
||
expect(step.description, 'Test step description');
|
||
});
|
||
|
||
test('создает Step с null значениями', () {
|
||
const step = Step();
|
||
|
||
expect(step.image, isNull);
|
||
expect(step.description, isNull);
|
||
});
|
||
|
||
test('fromJson создает Step из JSON', () {
|
||
final json = {
|
||
'image': 'https://example.com/image.jpg',
|
||
'description': 'Test step description',
|
||
};
|
||
|
||
final step = Step.fromJson(json);
|
||
|
||
expect(step.image, 'https://example.com/image.jpg');
|
||
expect(step.description, 'Test step description');
|
||
});
|
||
|
||
test('fromJson создает Step из JSON с null значениями', () {
|
||
final json = <String, dynamic>{};
|
||
|
||
final step = Step.fromJson(json);
|
||
|
||
expect(step.image, isNull);
|
||
expect(step.description, isNull);
|
||
});
|
||
|
||
test('toJson serializes Step correctly', () {
|
||
const step = Step(
|
||
image: 'https://example.com/image.jpg',
|
||
description: 'Test step description',
|
||
);
|
||
|
||
final json = step.toJson();
|
||
|
||
expect(json['image'], 'https://example.com/image.jpg');
|
||
expect(json['description'], 'Test step description');
|
||
});
|
||
|
||
test('toJson serializes Step with null values correctly', () {
|
||
const step = Step();
|
||
|
||
final json = step.toJson();
|
||
|
||
expect(json['image'], isNull);
|
||
expect(json['description'], isNull);
|
||
});
|
||
});
|
||
}
|