Refactor date handling in tender data model and UI components. Added unixTimestampFromJson for parsing timestamps and updated timeConvertor to handle null values. Updated relevant model fields and UI to use the new parsing logic. Added unit tests for date utilities.
This commit is contained in:
@@ -0,0 +1,20 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:tm_app/core/utils/date_utils.dart';
|
||||
|
||||
void main() {
|
||||
group('timeConvertor', () {
|
||||
test('returns dash for null and zero', () {
|
||||
expect(timeConvertor(null), '-');
|
||||
expect(timeConvertor(0), '-');
|
||||
});
|
||||
|
||||
test('formats unix seconds like moment.unix', () {
|
||||
expect(timeConvertor(1700000000), '2023-11-14');
|
||||
});
|
||||
|
||||
test('parses string timestamps from json', () {
|
||||
expect(unixTimestampFromJson('1700000000'), 1700000000);
|
||||
expect(unixTimestampFromJson(''), isNull);
|
||||
});
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user