Files
KiriMemo/test/study_plan_test.dart

58 lines
1.5 KiB
Dart
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
import 'package:flutter_test/flutter_test.dart';
import 'package:mobile/models/study_plan.dart';
void main() {
test('预计用时按条目数与平均耗时向上取整', () {
// 18 + 35 = 53 条 × 13 秒 = 689 秒 → 12 分钟
expect(StudyPlan.sample.itemCount, 53);
expect(StudyPlan.sample.estimatedMinutes, 12);
expect(StudyPlan.sample.estimatedLabel, '预计用时 12 分钟');
});
test('没有任务时不给时长承诺,也不算空转', () {
const StudyPlan plan = StudyPlan(
deckName: '空单元集',
algorithm: 'SM-2',
totalItems: 10,
activatedItems: 0,
dueItems: 0,
newItems: 0,
secondsPerItem: 13,
);
expect(plan.isEmpty, isTrue);
expect(plan.estimatedMinutes, 0);
expect(plan.estimatedLabel, '今天没有到期的内容');
});
test('完成度保留一位小数', () {
const StudyPlan plan = StudyPlan(
deckName: '高考必背古诗文',
algorithm: 'NSP-0',
totalItems: 950,
activatedItems: 295,
dueItems: 0,
newItems: 0,
secondsPerItem: 0,
);
expect(plan.progress, closeTo(0.3105, 0.0001));
expect(plan.progressPercent, '31.1%');
});
test('条目总数为 0 时不除零', () {
const StudyPlan plan = StudyPlan(
deckName: '空集',
algorithm: 'SM-2',
totalItems: 0,
activatedItems: 0,
dueItems: 0,
newItems: 0,
secondsPerItem: 13,
);
expect(plan.progress, 0);
expect(plan.progressPercent, '0.0%');
});
}