File tree Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Expand file tree Collapse file tree 2 files changed +12
-10
lines changed Original file line number Diff line number Diff line change @@ -1370,19 +1370,19 @@ class DateText extends StatelessWidget {
1370
1370
),
1371
1371
formatHeaderDate (
1372
1372
zulipLocalizations,
1373
- DateTime .fromMillisecondsSinceEpoch (timestamp * 1000 ),
1374
- now: ZulipBinding .instance.now ()));
1373
+ DateTime .fromMillisecondsSinceEpoch (timestamp * 1000 )));
1375
1374
}
1376
1375
}
1377
1376
1378
1377
@visibleForTesting
1379
1378
String formatHeaderDate (
1380
1379
ZulipLocalizations zulipLocalizations,
1381
- DateTime dateTime, {
1382
- required DateTime now,
1383
- }) {
1384
- assert (! dateTime.isUtc && ! now.isUtc,
1385
- '`dateTime` and `now` need to be in local time.' );
1380
+ DateTime dateTime,
1381
+ ) {
1382
+ assert (! dateTime.isUtc,
1383
+ '`dateTime` need to be in local time.' );
1384
+
1385
+ final now = ZulipBinding .instance.now ();
1386
1386
1387
1387
if (dateTime.year == now.year &&
1388
1388
dateTime.month == now.month &&
Original file line number Diff line number Diff line change 1
1
import 'dart:convert' ;
2
2
3
3
import 'package:checks/checks.dart' ;
4
+ import 'package:clock/clock.dart' ;
4
5
import 'package:collection/collection.dart' ;
5
6
import 'package:flutter/material.dart' ;
6
7
import 'package:flutter/rendering.dart' ;
@@ -1421,7 +1422,6 @@ void main() {
1421
1422
1422
1423
group ('formatHeaderDate' , () {
1423
1424
final zulipLocalizations = GlobalLocalizations .zulipLocalizations;
1424
- final now = DateTime .parse ("2023-01-10 12:00" );
1425
1425
final testCases = [
1426
1426
("2023-01-10 12:00" , zulipLocalizations.today),
1427
1427
("2023-01-10 00:00" , zulipLocalizations.today),
@@ -1436,8 +1436,10 @@ void main() {
1436
1436
];
1437
1437
for (final (dateTime, expected) in testCases) {
1438
1438
test ('$dateTime returns $expected ' , () {
1439
- check (formatHeaderDate (zulipLocalizations, DateTime .parse (dateTime), now: now))
1440
- .equals (expected);
1439
+ withClock (Clock .fixed (DateTime .parse ("2023-01-10 12:00" )), () {
1440
+ check (formatHeaderDate (zulipLocalizations, DateTime .parse (dateTime)))
1441
+ .equals (expected);
1442
+ });
1441
1443
});
1442
1444
}
1443
1445
});
You can’t perform that action at this time.
0 commit comments