@@ -55,6 +55,37 @@ void main() {
55
55
}
56
56
}
57
57
58
+ void testExpectedUrls (List <(String , String )> testCases, {
59
+ List <ZulipStream >? streams,
60
+ List <User >? users,
61
+ }) {
62
+ assert (streams != null || users != null );
63
+ for (final testCase in testCases) {
64
+ final String inputUrl = testCase.$1;
65
+ final String expectedUrl = testCase.$2;
66
+ test ('URL parsing: $inputUrl ' , () async {
67
+ final store = await setupStore (realmUrl: realmUrl, streams: streams, users: users);
68
+ final url = store.tryResolveUrl (inputUrl)! ;
69
+ check (url.toString ()).equals (expectedUrl);
70
+ });
71
+ }
72
+ }
73
+
74
+ group ('parseInternalLink full URL cases' , () {
75
+ final streams = [
76
+ eg.stream (streamId: 1 , name: 'check' ),
77
+ eg.stream (streamId: 3 , name: 'mobile' ),
78
+ ];
79
+
80
+ final fullUrlTestCases = [
81
+ ('https://example.com/#narrow/stream/check' , 'https://example.com/#narrow/stream/check' ),
82
+ ('https://example.com/#narrow/stream/3-mobile/topic/topic1' , 'https://example.com/#narrow/stream/3-mobile/topic/topic1' ),
83
+ ('https://another.com/#narrow/stream/mobile' , 'https://another.com/#narrow/stream/mobile' ),
84
+ ('https://example.com/#narrow/stream/check/topic/test' , 'https://example.com/#narrow/stream/check/topic/test' ),
85
+ ];
86
+ testExpectedUrls (fullUrlTestCases, streams: streams);
87
+ });
88
+
58
89
group ('parseInternalLink' , () {
59
90
final streams = [
60
91
eg.stream (streamId: 1 , name: 'check' ),
0 commit comments