Skip to content

Commit 006533e

Browse files
committed
internal_link_test: Create 'parseInternalLink full url cases' test
1 parent 1b20940 commit 006533e

File tree

1 file changed

+31
-0
lines changed

1 file changed

+31
-0
lines changed

test/model/internal_link_test.dart

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,37 @@ void main() {
5555
}
5656
}
5757

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+
5889
group('parseInternalLink', () {
5990
final streams = [
6091
eg.stream(streamId: 1, name: 'check'),

0 commit comments

Comments
 (0)