47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:cleanplate_shared/cleanplate_shared.dart';
|
|
import 'package:test/test.dart';
|
|
|
|
void main() {
|
|
group('RecipeValidator', () {
|
|
test('validateTitle returns null for valid title', () {
|
|
expect(RecipeValidator.validateTitle('My Recipe'), isNull);
|
|
});
|
|
|
|
test('validateTitle returns error for empty title', () {
|
|
expect(RecipeValidator.validateTitle(''), isNotNull);
|
|
});
|
|
|
|
test('validateServings returns null for valid servings', () {
|
|
expect(RecipeValidator.validateServings(4), isNull);
|
|
});
|
|
|
|
test('validateServings returns error for zero servings', () {
|
|
expect(RecipeValidator.validateServings(0), isNotNull);
|
|
});
|
|
|
|
test('validateRating returns null for valid rating', () {
|
|
expect(RecipeValidator.validateRating(5), isNull);
|
|
});
|
|
|
|
test('validateRating returns error for out-of-range rating', () {
|
|
expect(RecipeValidator.validateRating(6), isNotNull);
|
|
});
|
|
});
|
|
|
|
group('DietType', () {
|
|
test('displayName returns correct value', () {
|
|
expect(DietType.vegan.displayName, equals('Vegan'));
|
|
});
|
|
});
|
|
|
|
group('ApiConstants', () {
|
|
test('basePath includes version', () {
|
|
expect(ApiConstants.basePath, equals('/api/v1'));
|
|
});
|
|
|
|
test('recipe path includes id', () {
|
|
expect(ApiConstants.recipe('abc'), equals('/api/v1/recipes/abc'));
|
|
});
|
|
});
|
|
}
|