import 'package:cloudreve4_flutter/core/utils/file_utils.dart';
import 'package:flutter_test/flutter_test.dart';

void main() {
  group('FileUtils', () {
    test('decodePathForDisplay decodes encoded Chinese segments', () {
      expect(
        FileUtils.decodePathForDisplay(
          '/%E4%B8%AD%E6%96%87/%E8%B5%84%E6%96%99',
        ),
        '/\u4e2d\u6587/\u8d44\u6599',
      );
    });

    test('decodePathForDisplay leaves malformed percent sequences safe', () {
      expect(FileUtils.decodePathForDisplay('/100%/reports'), '/100%/reports');
    });

    test('toCloudreveUriWithQuery encodes query values', () {
      final uri = FileUtils.toCloudreveUriWithQuery('/folder', {
        'name': '\u4e2d\u6587 \u6587\u6863',
      });

      expect(uri, contains('cloudreve://my/folder?name='));
      expect(uri, contains('%E4%B8%AD%E6%96%87'));
      expect(
        Uri.parse(uri).queryParameters['name'],
        '\u4e2d\u6587 \u6587\u6863',
      );
    });
  });
}
