consolidated downloads dir, nextcloud origin, upload route and chat timestamps; added webdav path tests
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:marianum_mobile/view/pages/files/data/webdav_path.dart';
|
||||
|
||||
void main() {
|
||||
group('webdavSegmentsOf', () {
|
||||
test('root is empty', () {
|
||||
expect(webdavSegmentsOf(''), isEmpty);
|
||||
expect(webdavSegmentsOf('/'), isEmpty);
|
||||
});
|
||||
|
||||
test('strips edge slashes of folders and files', () {
|
||||
expect(webdavSegmentsOf('a/b/'), ['a', 'b']);
|
||||
expect(webdavSegmentsOf('/a/b/c.txt'), ['a', 'b', 'c.txt']);
|
||||
});
|
||||
});
|
||||
|
||||
group('webdavParentSegmentsOf', () {
|
||||
test('drops the last segment', () {
|
||||
expect(webdavParentSegmentsOf('a/b/c.txt'), ['a', 'b']);
|
||||
expect(webdavParentSegmentsOf('a/'), isEmpty);
|
||||
});
|
||||
|
||||
test('root has no parent', () {
|
||||
expect(webdavParentSegmentsOf(''), isEmpty);
|
||||
});
|
||||
});
|
||||
|
||||
test('webdavFolderPath ends folders with a slash, root stays empty', () {
|
||||
expect(webdavFolderPath(const []), '');
|
||||
expect(webdavFolderPath(const ['a', 'b']), 'a/b/');
|
||||
});
|
||||
|
||||
test('webdavJoin marks directories with a trailing slash', () {
|
||||
expect(webdavJoin('a/', 'b', isDirectory: true), 'a/b/');
|
||||
expect(webdavJoin('', 'c.txt', isDirectory: false), 'c.txt');
|
||||
});
|
||||
|
||||
test('listFilesCacheKey maps root to a single slash', () {
|
||||
expect(listFilesCacheKey(const []), '/');
|
||||
expect(listFilesCacheKey(const ['a', 'b']), 'a/b');
|
||||
});
|
||||
|
||||
test('folder path round-trips through segments', () {
|
||||
const segments = ['Schule', 'Mathe'];
|
||||
expect(webdavSegmentsOf(webdavFolderPath(segments)), segments);
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user