Files
eatvio_app/test/features/create_recipe/models/step_test.dart
2026-01-14 18:47:11 +03:00

66 lines
1.8 KiB
Dart
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
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);
});
});
}