@@ -2,14 +2,14 @@ import 'package:flutter_test/flutter_test.dart';
22import 'package:http_interceptor/utils.dart' ;
33
44main () {
5- group ("addParametersToUrl " , () {
5+ group ("addParametersToStringUrl " , () {
66 test ("Adds parameters to a URL string without parameters" , () {
77 // Arrange
88 String url = "https://www.google.com/helloworld" ;
99 Map <String , String > parameters = {"foo" : "bar" , "num" : "0" };
1010
1111 // Act
12- String parameterUrl = addParametersToUrl (url, parameters);
12+ String parameterUrl = addParametersToStringUrl (url, parameters);
1313
1414 // Assert
1515 expect (parameterUrl,
@@ -21,7 +21,7 @@ main() {
2121 Map <String , String > parameters = {"extra" : "1" , "extra2" : "anotherone" };
2222
2323 // Act
24- String parameterUrl = addParametersToUrl (url, parameters);
24+ String parameterUrl = addParametersToStringUrl (url, parameters);
2525
2626 // Assert
2727 expect (
@@ -30,4 +30,35 @@ main() {
3030 "https://www.google.com/helloworld?foo=bar&num=0&extra=1&extra2=anotherone" ));
3131 });
3232 });
33+ group ("addParametersToUrl" , () {
34+ test ("Add parameters to Uri Url without parameters" , () {
35+ // Arrange
36+ String stringUrl = "https://www.google.com/helloworld" ;
37+ Map <String , String > parameters = {"foo" : "bar" , "num" : "0" };
38+ Uri url = Uri .parse (stringUrl);
39+
40+ // Act
41+ Uri parameterUri = addParametersToUrl (url, parameters);
42+
43+ // Assert
44+ Uri expectedUrl = Uri .https ("www.google.com" , "/helloworld" , parameters);
45+ expect (parameterUri, equals (expectedUrl));
46+ });
47+ test ("Add parameters to Uri Url with parameters" , () {
48+ // Arrange
49+ String authority = "www.google.com" ;
50+ String unencodedPath = "/helloworld" ;
51+ Map <String , String > someParameters = {"foo" : "bar" };
52+ Map <String , String > otherParameters = {"num" : "0" };
53+ Uri url = Uri .https (authority, unencodedPath, someParameters);
54+
55+ // Act
56+ Uri parameterUri = addParametersToUrl (url, otherParameters);
57+
58+ // Assert
59+ Map <String , String > allParameters = {"foo" : "bar" , "num" : "0" };
60+ Uri expectedUrl = Uri .https ("www.google.com" , "/helloworld" , allParameters);
61+ expect (parameterUri, equals (expectedUrl));
62+ });
63+ });
3364}
0 commit comments