|
1 | 1 | import 'package:checks/checks.dart'; |
2 | 2 | import 'package:test/scaffolding.dart'; |
3 | 3 | import 'package:zulip/api/model/events.dart'; |
| 4 | +import 'package:zulip/api/model/model.dart'; |
4 | 5 | import 'package:zulip/model/compose.dart'; |
5 | 6 | import 'package:zulip/model/localizations.dart'; |
6 | 7 | import 'package:zulip/model/store.dart'; |
@@ -334,6 +335,38 @@ hello |
334 | 335 | }); |
335 | 336 | }); |
336 | 337 |
|
| 338 | + test('fallbackMarkdownLink', () async { |
| 339 | + final store = eg.store(); |
| 340 | + final channels = [ |
| 341 | + eg.stream(streamId: 1, name: '`code`'), |
| 342 | + eg.stream(streamId: 2, name: 'score > 90'), |
| 343 | + eg.stream(streamId: 3, name: 'A*'), |
| 344 | + eg.stream(streamId: 4, name: 'R&D'), |
| 345 | + eg.stream(streamId: 5, name: 'UI [v2]'), |
| 346 | + eg.stream(streamId: 6, name: r'Save $$'), |
| 347 | + ]; |
| 348 | + await store.addStreams(channels); |
| 349 | + |
| 350 | + check(fallbackMarkdownLink(store: store, |
| 351 | + channel: channels[1 - 1])) |
| 352 | + .equals('[`code`](#narrow/channel/1-.60code.60)'); |
| 353 | + check(fallbackMarkdownLink(store: store, |
| 354 | + channel: channels[2 - 1], topic: TopicName('topic'))) |
| 355 | + .equals('[score > 90 > topic](#narrow/channel/2-score-.3E-90/topic/topic)'); |
| 356 | + check(fallbackMarkdownLink(store: store, |
| 357 | + channel: channels[3 - 1], topic: TopicName('R&D'))) |
| 358 | + .equals('[A* > R&D](#narrow/channel/3-A*/topic/R.26D)'); |
| 359 | + check(fallbackMarkdownLink(store: store, |
| 360 | + channel: channels[4 - 1], topic: TopicName('topic'), nearMessageId: 10)) |
| 361 | + .equals('[R&D > topic @ 💬](#narrow/channel/4-R.26D/topic/topic/near/10)'); |
| 362 | + check(fallbackMarkdownLink(store: store, |
| 363 | + channel: channels[5 - 1], topic: TopicName(r'Save $$'), nearMessageId: 10)) |
| 364 | + .equals('[UI [v2] > Save $$ @ 💬](#narrow/channel/5-UI-.5Bv2.5D/topic/Save.20.24.24/near/10)'); |
| 365 | + check(() => fallbackMarkdownLink(store: store, |
| 366 | + channel: channels[6 - 1], nearMessageId: 10)) |
| 367 | + .throws<AssertionError>(); |
| 368 | + }); |
| 369 | + |
337 | 370 | test('inlineLink', () { |
338 | 371 | check(inlineLink('CZO', 'https://chat.zulip.org/')).equals('[CZO](https://chat.zulip.org/)'); |
339 | 372 | check(inlineLink('Uploading file.txt…', '')).equals('[Uploading file.txt…]()'); |
|
0 commit comments