Files
pipelines/app/test/features/chat/files/files_urls_test.dart
T

28 lines
1.0 KiB
Dart

import 'package:flutter_test/flutter_test.dart';
import 'package:pipelines_app/features/chat/files/files_urls.dart';
void main() {
test('resolves view and attachment urls with encoded paths', () {
final urls = fileUrls(
'ws://example.test:8081/connect?old=1',
'~/My folder/naïve file.txt',
);
expect(urls, isNotNull);
expect(urls!.view.path, '/files');
expect(urls.view.queryParameters['path'], '~/My folder/naïve file.txt');
expect(urls.view.toString(), contains('My+folder'));
expect(urls.view.toString(), contains('na%C3%AFve+file.txt'));
expect(urls.download.queryParameters['download'], '1');
});
test('preserves whitespace in actual filenames', () {
final urls = fileUrls('ws://example.test/connect', '/home/file.txt ');
expect(urls!.view.queryParameters['path'], '/home/file.txt ');
});
test('rejects a missing or invalid endpoint', () {
expect(fileUrls('', '/tmp/a.txt'), isNull);
expect(fileUrls('http://example.test/connect', '/tmp/a.txt'), isNull);
});
}