feat: study home with daily plan card and quick actions
This commit is contained in:
1 parent
277ead9fe7
commit
0423027e97
4 files changed
+452
-6
No files matched your search
@@ -0,0 +1,57 @@
|
||||
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%');
|
||||
});
|
||||
}
|
||||
Reference in new issue
Block a user