Initial commit: CleanPlate shared Dart package
Domain models, enums, constants, validators shared between frontend and backend.
This commit is contained in:
46
test/cleanplate_shared_test.dart
Normal file
46
test/cleanplate_shared_test.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
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'));
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user