forked from eatvio/eatvio_app
Merge remote-tracking branch 'upstream/main'
This commit is contained in:
@@ -18,8 +18,13 @@ enum PortionState {
|
||||
@JsonValue('eaten_edited')
|
||||
eatenEdited,
|
||||
commented,
|
||||
@JsonValue('commented_from_diet')
|
||||
commentedFromDiet,
|
||||
@JsonValue('reviewed_by_user')
|
||||
reviewedByUser,
|
||||
@JsonValue('reviewed_from_diet')
|
||||
reviewedFromDiet,
|
||||
unknown,
|
||||
}
|
||||
|
||||
@freezed
|
||||
@@ -138,7 +143,7 @@ abstract class PortionModel with _$PortionModel {
|
||||
@JsonKey(name: "quantity") required int quantity,
|
||||
@JsonKey(name: "portion") required String portion,
|
||||
@JsonKey(name: "from_diet") required bool fromDiet,
|
||||
@JsonKey(name: "state") required PortionState portionState,
|
||||
@JsonKey(name: "state", unknownEnumValue: PortionState.unknown) required PortionState portionState,
|
||||
}) = _PortionModel;
|
||||
|
||||
factory PortionModel.fromJson(Map<String, dynamic> json) => _$PortionModelFromJson(json);
|
||||
|
||||
22
pubspec.yaml
22
pubspec.yaml
@@ -1,6 +1,6 @@
|
||||
name: eatvio_app
|
||||
description: A new Flutter project.
|
||||
version: 1.3.56+145
|
||||
version: 1.3.57+146
|
||||
publish_to: 'none'
|
||||
|
||||
environment:
|
||||
@@ -175,14 +175,14 @@ flutter_intl:
|
||||
flutter_native_splash:
|
||||
android: true
|
||||
ios: true
|
||||
color: '#FFFFFF'
|
||||
image_android: 'assets/splash/splash.png'
|
||||
image_dark_android: 'assets/splash/splash.png'
|
||||
image_ios: 'assets/splash/splash.png'
|
||||
image_dark_ios: 'assets/splash/splash.png'
|
||||
branding_android: 'assets/splash/branding.png'
|
||||
branding_dark_android: 'assets/splash/branding.png'
|
||||
color: "#FFFFFF"
|
||||
image_android: "assets/splash/splash.png"
|
||||
image_dark_android: "assets/splash/splash.png"
|
||||
image_ios: "assets/splash/splash.png"
|
||||
image_dark_ios: "assets/splash/splash.png"
|
||||
branding_android: "assets/splash/branding.png"
|
||||
branding_dark_android: "assets/splash/branding.png"
|
||||
android_12:
|
||||
image: 'assets/splash/splash.png'
|
||||
image_dark: 'assets/splash/splash.png'
|
||||
branding: 'assets/splash/branding.png'
|
||||
image: "assets/splash/splash.png"
|
||||
image_dark: "assets/splash/splash.png"
|
||||
branding: "assets/splash/branding.png"
|
||||
|
||||
@@ -4,14 +4,48 @@ import 'package:flutter_test/flutter_test.dart';
|
||||
void main() {
|
||||
group('PortionState enum', () {
|
||||
test('has all expected values', () {
|
||||
expect(PortionState.values.length, 7);
|
||||
expect(PortionState.values.length, 10);
|
||||
expect(PortionState.filledDiet, isNotNull);
|
||||
expect(PortionState.eatenFromDiet, isNotNull);
|
||||
expect(PortionState.eaten, isNotNull);
|
||||
expect(PortionState.eatenDeleted, isNotNull);
|
||||
expect(PortionState.eatenEdited, isNotNull);
|
||||
expect(PortionState.commented, isNotNull);
|
||||
expect(PortionState.commentedFromDiet, isNotNull);
|
||||
expect(PortionState.reviewedByUser, isNotNull);
|
||||
expect(PortionState.reviewedFromDiet, isNotNull);
|
||||
expect(PortionState.unknown, isNotNull);
|
||||
});
|
||||
});
|
||||
|
||||
group('PortionModel.fromJson', () {
|
||||
Map<String, dynamic> portionJson({required String state}) => {
|
||||
'id': 1,
|
||||
'product_nutritional_value_id': null,
|
||||
'product_calories_info': null,
|
||||
'product_name': 'Oatmeal',
|
||||
'quantity': 1,
|
||||
'portion': '100g',
|
||||
'from_diet': true,
|
||||
'state': state,
|
||||
};
|
||||
|
||||
test('parses commented_from_diet state', () {
|
||||
final model = PortionModel.fromJson(portionJson(state: 'commented_from_diet'));
|
||||
|
||||
expect(model.portionState, PortionState.commentedFromDiet);
|
||||
});
|
||||
|
||||
test('parses reviewed_from_diet state', () {
|
||||
final model = PortionModel.fromJson(portionJson(state: 'reviewed_from_diet'));
|
||||
|
||||
expect(model.portionState, PortionState.reviewedFromDiet);
|
||||
});
|
||||
|
||||
test('does not throw on unknown state from backend', () {
|
||||
final model = PortionModel.fromJson(portionJson(state: 'some_future_state'));
|
||||
|
||||
expect(model.portionState, PortionState.unknown);
|
||||
});
|
||||
});
|
||||
|
||||
|
||||
Reference in New Issue
Block a user