v1.1.4 getPropertyDate
This commit is contained in:
+28
-2
@@ -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));
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user