mirror of
https://github.com/wanghongenpin/proxypin.git
synced 2026-06-01 17:15:48 +08:00
This commit is contained in:
46
test/multi_select_controller_test.dart
Normal file
46
test/multi_select_controller_test.dart
Normal file
@@ -0,0 +1,46 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:proxypin/ui/component/multi_select_controller.dart';
|
||||
|
||||
void main() {
|
||||
group('MultiSelectController', () {
|
||||
test('toggle enables and clears selection mode', () {
|
||||
final controller = MultiSelectController();
|
||||
|
||||
controller.toggle('a');
|
||||
expect(controller.isSelectionMode, isTrue);
|
||||
expect(controller.selectedIds, {'a'});
|
||||
|
||||
controller.toggle('a');
|
||||
expect(controller.isSelectionMode, isFalse);
|
||||
expect(controller.selectedIds, isEmpty);
|
||||
});
|
||||
|
||||
test('selectRange uses anchor item', () {
|
||||
final controller = MultiSelectController();
|
||||
controller.selectOnly('b');
|
||||
|
||||
controller.selectRange(['a', 'b', 'c', 'd'], 'd');
|
||||
|
||||
expect(controller.selectedIds, {'b', 'c', 'd'});
|
||||
});
|
||||
|
||||
test('selectAll and prune keep only visible ids', () {
|
||||
final controller = MultiSelectController();
|
||||
|
||||
controller.prune(['b', 'c', 'd']);
|
||||
|
||||
expect(controller.isSelectionMode, isTrue);
|
||||
expect(controller.selectedIds, {'b', 'c'});
|
||||
});
|
||||
|
||||
test('prune clears selection mode when all selected ids disappear', () {
|
||||
final controller = MultiSelectController();
|
||||
|
||||
controller.prune(['c']);
|
||||
|
||||
expect(controller.isSelectionMode, isFalse);
|
||||
expect(controller.selectedIds, isEmpty);
|
||||
});
|
||||
});
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user