mirror of
https://github.com/immich-app/immich.git
synced 2024-11-28 09:33:27 +02:00
bffc2cdf60
* refactor: move all extensions to separate package * refactor(mobile): add BuildContext extension * refactor(mobile): use theme getters from context * refactor(mobile): use media query size from context * refactor(mobile): use auto router methods from context * refactor(mobile): use navigator methods from context --------- Co-authored-by: shalong-tanwen <139912620+shalong-tanwen@users.noreply.github.com>
56 lines
1.4 KiB
Dart
56 lines
1.4 KiB
Dart
import 'package:flutter_test/flutter_test.dart';
|
|
import 'package:immich_mobile/extensions/collection_extensions.dart';
|
|
import 'package:immich_mobile/extensions/string_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(
|
|
compare: (s1, s2) => s1.length.compareTo(s2.length),
|
|
),
|
|
["a", "bb", "ddd"],
|
|
);
|
|
});
|
|
});
|
|
}
|