v1.1.4 getPropertyDate
This commit is contained in:
parent
3bc2b74f74
commit
7e3d99b9a3
@ -1,5 +1,8 @@
|
||||
Workout Test and Diet 4 You Common Util Functions
|
||||
|
||||
### Version 1.1.4
|
||||
- customer.getPropertyDate
|
||||
|
||||
### Version 1.1.3
|
||||
- CupertinoPicker error in Flutter 3.10 stable
|
||||
|
||||
|
@ -133,6 +133,18 @@ class Customer {
|
||||
}
|
||||
}
|
||||
|
||||
String getPropertyDate(String propertyName) {
|
||||
if (properties[propertyName] == null) {
|
||||
return "";
|
||||
} else {
|
||||
if (properties[propertyName]!.dateAdd == null) {
|
||||
return "";
|
||||
} else {
|
||||
return DateFormat('yyyy-MM-dd').format(properties[propertyName]!.dateAdd!);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
setProperty(String propertyName, double value) {
|
||||
properties[propertyName]!.propertyValue = value;
|
||||
}
|
||||
|
@ -1,6 +1,6 @@
|
||||
name: workouttest_util
|
||||
description: Workout Test app and web functions.
|
||||
version: 1.1.3
|
||||
version: 1.1.4
|
||||
|
||||
environment:
|
||||
sdk: ">=2.18.6 <4.0.0"
|
||||
|
@ -1,13 +1,16 @@
|
||||
import 'dart:convert';
|
||||
|
||||
import 'package:intl/intl.dart';
|
||||
import 'package:flutter_dotenv/flutter_dotenv.dart';
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:workouttest_util/model/cache.dart';
|
||||
import 'package:workouttest_util/model/customer.dart';
|
||||
import 'package:workouttest_util/model/customer_property.dart';
|
||||
import 'package:workouttest_util/model/property.dart';
|
||||
import 'package:workouttest_util/repository/customer_repository.dart';
|
||||
|
||||
main() {
|
||||
setUp(() {
|
||||
setUp(() async {
|
||||
await dotenv.load(fileName: "assets/.env");
|
||||
String propertyJson = '''
|
||||
[
|
||||
{
|
||||
@ -113,4 +116,27 @@ main() {
|
||||
expect(customer.getProperty("Weight"), 66);
|
||||
});
|
||||
});
|
||||
|
||||
test('getPropertyDate', () {
|
||||
var customer = Customer();
|
||||
var propertyName = 'testDate';
|
||||
|
||||
var testDate = DateTime.now();
|
||||
var expectedDate = DateFormat('yyyy-MM-dd').format(testDate);
|
||||
|
||||
String json = '''{
|
||||
"customerPropertyId": 41,
|
||||
"propertyId": 1,
|
||||
"propertyValue": 82.0,
|
||||
"dateAdd": "$expectedDate",
|
||||
"goal": false
|
||||
}''';
|
||||
|
||||
CustomerProperty property = CustomerProperty.fromJson(jsonDecode(json));
|
||||
customer.properties[propertyName] = property;
|
||||
|
||||
var actualDate = customer.getPropertyDate(propertyName);
|
||||
|
||||
expect(actualDate, equals(expectedDate));
|
||||
});
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user