feat: 严格确保万托林先行吸入,退出会话界面不中断计时(支持后台持续倒计时与主页悬浮卡片)
This commit is contained in:
@@ -43,4 +43,36 @@ void main() {
|
||||
expect(find.text('42'), findsOneWidget);
|
||||
expect(find.text('/ 60 喷剩余'), findsOneWidget);
|
||||
});
|
||||
|
||||
test('Clinical ordering: Ventolin must always precede Flixotide', () {
|
||||
final flixotide = Canister(
|
||||
id: 'flixotide',
|
||||
name: '辅舒酮',
|
||||
totalDoses: 60,
|
||||
remainingDoses: 60,
|
||||
openedAt: DateTime.now(),
|
||||
isSteroid: true,
|
||||
sortOrder: 2,
|
||||
);
|
||||
final ventolin = Canister(
|
||||
id: 'ventolin',
|
||||
name: '万托林',
|
||||
totalDoses: 200,
|
||||
remainingDoses: 200,
|
||||
openedAt: DateTime.now(),
|
||||
isSteroid: false,
|
||||
sortOrder: 1,
|
||||
);
|
||||
|
||||
// Even if inserted in reverse order [Flixotide, Ventolin]
|
||||
final list = [flixotide, ventolin];
|
||||
list.sort((a, b) {
|
||||
if (!a.isSteroid && b.isSteroid) return -1;
|
||||
if (a.isSteroid && !b.isSteroid) return 1;
|
||||
return a.sortOrder.compareTo(b.sortOrder);
|
||||
});
|
||||
|
||||
expect(list.first.name, '万托林');
|
||||
expect(list.last.name, '辅舒酮');
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user