Testing
Tempo includes a
testing
library with a useful set of matchers for your unit tests that produce helpful
error messages.
import 'package:tempo/testing.dart';
var dt = LocalDateTime(2020, 1, 2, 3, 4);
expect(dt, hasYear(2020));
expect(dt, hasHour(4));
expect(dt, hasDate(2020, 1, 2));
expect(dt, hasTime(3, 4));All now() constructors use the
clock package. Which means you can
substitute a known value for the current time in tests:
import 'package:clock/clock.dart';
import 'package:tempo/testing.dart';
var date = withClock(Clock.fixed(DateTime(2000, 1, 2)), () => LocalDate.now());
expect(date, hasDate(2000, 1, 2));