@@ -221,25 +221,44 @@ void main() {
221
221
testExpectedNarrows (testCases, streams: streams);
222
222
});
223
223
224
- group ('"/#narrow/is/mentioned returns expected MentionsNarrow' , () {
225
- final testCases = [
226
- ('/#narrow/is/mentioned' , const MentionsNarrow ()),
227
- ('/#narrow/is/mentioned/near/1' , const MentionsNarrow ()),
228
- ('/#narrow/is/mentioned/with/2' , const MentionsNarrow ()),
229
- ('/#narrow/channel/7-test-here/is/mentioned' , null ),
230
- ('/#narrow/channel/check/topic/test/is/mentioned' , null ),
231
- ('/#narrow/topic/test/is/mentioned' , null ),
232
- ('/#narrow/dm/17327-Chris-Bobbe-(Test-Account)/is/mentioned' , null ),
233
- ('/#narrow/-is/mentioned' , null ),
234
- ];
235
- testExpectedNarrows (testCases, streams: streams);
224
+ group ('/#narrow/is/<...> returns corresponding narrow' , () {
225
+ // For these tests, we are more interested in the internal links
226
+ // containing a single effective `is` operator.
227
+ // Internal links with multiple operators should be tested separately.
228
+ for (final operand in IsOperand .values) {
229
+ List <(String , Narrow ?)> sharedCases (Narrow ? narrow) => [
230
+ ('/#narrow/is/$operand ' , narrow),
231
+ ('/#narrow/is/$operand /near/1' , narrow),
232
+ ('/#narrow/is/$operand /with/2' , narrow),
233
+ ('/#narrow/channel/7-test-here/is/$operand ' , null ),
234
+ ('/#narrow/channel/check/topic/test/is/$operand ' , null ),
235
+ ('/#narrow/topic/test/is/$operand ' , null ),
236
+ ('/#narrow/dm/17327-Chris-Bobbe-(Test-Account)/is/$operand ' , null ),
237
+ ('/#narrow/-is/$operand ' , null ),
238
+ ];
239
+ final List <(String , Narrow ?)> testCases;
240
+ switch (operand) {
241
+ case IsOperand .mentioned:
242
+ testCases = sharedCases (const MentionsNarrow ());
243
+ case IsOperand .dm:
244
+ case IsOperand .private:
245
+ case IsOperand .alerted:
246
+ case IsOperand .starred:
247
+ case IsOperand .followed:
248
+ case IsOperand .resolved:
249
+ case IsOperand .unread:
250
+ case IsOperand .unknown:
251
+ // Unsupported operands should not return any narrow.
252
+ testCases = sharedCases (null );
253
+ }
254
+ testExpectedNarrows (testCases, streams: streams);
255
+ }
236
256
});
237
257
238
258
group ('unexpected link shapes are rejected' , () {
239
259
final testCases = [
240
260
('/#narrow/stream/name/topic/' , null ), // missing operand
241
261
('/#narrow/stream/name/unknown/operand/' , null ), // unknown operator
242
- ('/#narrow/is/starred' , null ), // unknown `is` operand
243
262
];
244
263
testExpectedNarrows (testCases, streams: streams);
245
264
});
0 commit comments