Files
SpotiFLAC-Mobile/test/issue_542_utils_test.dart
T
zarzet 17b210749f chore(backup): remove test-only legacy envelope helpers
New backups are written as archives; buildEnvelope and encode were only test
fixtures. The legacy restore test now spells out the old JSON envelope.
2026-10-23 22:43:23 +07:00

38 lines
1.4 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:mornye/utils/isrc_utils.dart';
import 'package:mornye/utils/ordered_range_selection.dart';
void main() {
group('issue 542 utility behavior', () {
test('formats valid ISRC for display without changing canonical value', () {
expect(formatIsrcForDisplay('aa9bq2200061'), 'AA-9BQ-22-00061');
expect(normalizeIsrc('AA-9BQ-22-00061'), 'AA9BQ2200061');
expect(canonicalIsrcForCopy('aa-9bq-22-00061'), 'AA9BQ2200061');
expect(formatIsrcForDisplay('not-an-isrc'), 'not-an-isrc');
expect(canonicalIsrcForCopy('not-an-isrc'), 'not-an-isrc');
});
test('range selection follows the user direction and insertion order', () {
final selected = <String>{'d'};
final anchor = addOrderedSelectionRange(
selected: selected,
visibleItems: const ['a', 'b', 'c', 'd', 'e'],
anchor: 'd',
target: 'b',
);
expect(anchor, 'b');
expect(selected.toList(), const ['d', 'c', 'b']);
});
test('single selection toggle keeps the latest selected anchor', () {
final selected = <String>{};
expect(toggleOrderedSelection(selected: selected, target: 'a'), 'a');
expect(toggleOrderedSelection(selected: selected, target: 'c'), 'c');
expect(toggleOrderedSelection(selected: selected, target: 'c'), 'a');
expect(selected.toList(), const ['a']);
});
});
}