Refactor profiles
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
import 'package:flutter_test/flutter_test.dart';
|
||||
import 'package:hiddify/domain/profiles/profiles.dart';
|
||||
import 'package:hiddify/features/profile/data/profile_parser.dart';
|
||||
import 'package:hiddify/features/profile/model/profile_entity.dart';
|
||||
|
||||
void main() {
|
||||
const validBaseUrl = "https://example.com/configurations/user1/filename.yaml";
|
||||
@@ -8,14 +9,26 @@ void main() {
|
||||
const validSupportUrl = "https://example.com/support";
|
||||
|
||||
group(
|
||||
"profile fromResponse",
|
||||
"parse",
|
||||
() {
|
||||
test(
|
||||
"with no additional metadata",
|
||||
"url with file extension, no headers",
|
||||
() {
|
||||
final profile = Profile.fromResponse(validExtendedUrl, {});
|
||||
final profile = ProfileParser.parse(validBaseUrl, {});
|
||||
|
||||
expect(profile.name, equals("filename"));
|
||||
expect(profile.url, equals(validBaseUrl));
|
||||
expect(profile.options, isNull);
|
||||
expect(profile.subInfo, isNull);
|
||||
},
|
||||
);
|
||||
|
||||
test(
|
||||
"url with url, no headers",
|
||||
() {
|
||||
final profile = ProfileParser.parse(validExtendedUrl, {});
|
||||
|
||||
expect(profile.name, equals("b"));
|
||||
expect(profile.url, equals(validExtendedUrl));
|
||||
expect(profile.options, isNull);
|
||||
expect(profile.subInfo, isNull);
|
||||
@@ -23,7 +36,7 @@ void main() {
|
||||
);
|
||||
|
||||
test(
|
||||
"with all metadata",
|
||||
"with base64 profile-title header",
|
||||
() {
|
||||
final headers = <String, List<String>>{
|
||||
"profile-title": ["base64:ZXhhbXBsZVRpdGxl"],
|
||||
@@ -34,7 +47,7 @@ void main() {
|
||||
"profile-web-page-url": [validBaseUrl],
|
||||
"support-url": [validSupportUrl],
|
||||
};
|
||||
final profile = Profile.fromResponse(validExtendedUrl, headers);
|
||||
final profile = ProfileParser.parse(validExtendedUrl, headers);
|
||||
|
||||
expect(profile.name, equals("exampleTitle"));
|
||||
expect(profile.url, equals(validExtendedUrl));
|
||||
Reference in New Issue
Block a user