47 lines
1.3 KiB
Dart
47 lines
1.3 KiB
Dart
import 'package:flutter/material.dart';
|
|
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:aero_track/models/canister.dart';
|
|
import 'package:aero_track/models/app_settings.dart';
|
|
import 'package:aero_track/widgets/puff_progress_ring.dart';
|
|
|
|
void main() {
|
|
TestWidgetsFlutterBinding.ensureInitialized();
|
|
|
|
test('Canister dose calculation test', () {
|
|
final canister = Canister(
|
|
id: 'test_c',
|
|
name: '辅舒酮',
|
|
totalDoses: 60,
|
|
remainingDoses: 42,
|
|
openedAt: DateTime.now(),
|
|
);
|
|
|
|
expect(canister.totalDoses, 60);
|
|
expect(canister.remainingDoses, 42);
|
|
expect(canister.percentRemaining, closeTo(42 / 60, 0.001));
|
|
expect(canister.isLowDose, false);
|
|
});
|
|
|
|
test('AppSettings cross-drug interval defaults to 5 minutes (300 seconds)', () {
|
|
final settings = AppSettings();
|
|
expect(settings.crossDrugIntervalSeconds, 300);
|
|
expect(settings.inhalationDurationSeconds, 15);
|
|
});
|
|
|
|
testWidgets('PuffProgressRing renders remaining dose correctly', (WidgetTester tester) async {
|
|
await tester.pumpWidget(
|
|
const MaterialApp(
|
|
home: Scaffold(
|
|
body: PuffProgressRing(
|
|
currentDoses: 42,
|
|
totalDoses: 60,
|
|
),
|
|
),
|
|
),
|
|
);
|
|
|
|
expect(find.text('42'), findsOneWidget);
|
|
expect(find.text('/ 60 喷剩余'), findsOneWidget);
|
|
});
|
|
}
|