1
0
mirror of https://github.com/immich-app/immich.git synced 2024-12-21 01:39:59 +02:00
immich/mobile/test/builtin_extensions_text.dart
Fynn Petersen-Frey 1a64075027
fix(mobile): fix asset removal edge cases (#2251)
Co-authored-by: Fynn Petersen-Frey <zoodyy@users.noreply.github.com>
Co-authored-by: Alex <alex.tran1502@gmail.com>
2023-04-14 20:50:58 -05:00

50 lines
1.2 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:immich_mobile/utils/builtin_extensions.dart';
void main() {
group('Test toDuration', () {
test('ok', () {
expect(
"1:02:33".toDuration(),
const Duration(hours: 1, minutes: 2, seconds: 33),
);
});
test('malformed', () {
expect("".toDuration(), null);
expect("1:2".toDuration(), null);
expect("a:b:c".toDuration(), null);
});
});
group('Test uniqueConsecutive', () {
test('empty', () {
final a = [];
expect(a.uniqueConsecutive(), []);
});
test('singleElement', () {
final a = [5];
expect(a.uniqueConsecutive(), [5]);
});
test('noDuplicates', () {
final a = [1, 2, 3];
expect(a.uniqueConsecutive(), [1, 2, 3]);
});
test('unsortedDuplicates', () {
final a = [1, 2, 1, 3];
expect(a.uniqueConsecutive(), [1, 2, 1, 3]);
});
test('sortedDuplicates', () {
final a = [6, 6, 2, 3, 3, 3, 4, 5, 1, 1];
expect(a.uniqueConsecutive(), [6, 2, 3, 4, 5, 1]);
});
test('withKey', () {
final a = ["a", "bb", "cc", "ddd"];
expect(a.uniqueConsecutive((s) => s.length), ["a", "bb", "ddd"]);
});
});
}