29 lines
1.1 KiB
Dart
29 lines
1.1 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:fuel_tax_tracker/services/estimated_refund.dart';
|
|
|
|
void main() {
|
|
test('the rate itself is 12.5 cents per gallon', () {
|
|
expect(moHighwayFuelTaxRefundRatePerGallon, 0.125);
|
|
});
|
|
|
|
test('multiplies whole gallons by the rate', () {
|
|
expect(estimatedFuelRefund(10), 1.25);
|
|
expect(estimatedFuelRefund(20), 2.50);
|
|
expect(estimatedFuelRefund(0), 0);
|
|
});
|
|
|
|
test('rounds fractional gallons to the nearest whole gallon before multiplying', () {
|
|
// 10.523 rounds up to 11 gallons: 11 * $0.125 = $1.375, floored to $1.37.
|
|
expect(estimatedFuelRefund(10.523), 1.37);
|
|
// 10.4 rounds down to 10 gallons: 10 * $0.125 = $1.25 exactly.
|
|
expect(estimatedFuelRefund(10.4), 1.25);
|
|
});
|
|
|
|
test('rounds the resulting cents down, never up', () {
|
|
// 1 gallon * $0.125 = $0.125 — rounding to the nearest cent would give
|
|
// $0.13, but this must floor to $0.12 instead.
|
|
expect(estimatedFuelRefund(1), 0.12);
|
|
// 3 gallons * $0.125 = $0.375 — floors to $0.37, not $0.38.
|
|
expect(estimatedFuelRefund(3), 0.37);
|
|
});
|
|
}
|