@@ -286,4 +286,45 @@ void main() {
286286 reason: 'Insertion within link label updates label' );
287287 });
288288 });
289+
290+ group ('AutoFormatMultipleLinksRule' , () {
291+ const rule = AutoFormatMultipleLinksRule ();
292+
293+ final validLinks = [
294+ 'http://google.com' ,
295+ 'https://www.google.com' ,
296+ 'http://beginner.example.edu/#act' ,
297+ 'http://beginner.example.edu#act' ,
298+ 'https://birth.example.net/beds/ants.php#bait' ,
299+ 'http://example.com/babies' ,
300+ 'https://www.example.com/' ,
301+ 'https://attack.example.edu/?acoustics=blade&bed=bed' ,
302+ 'https://attack.example.edu?acoustics=blade&bed=bed' ,
303+ 'http://basketball.example.com/' ,
304+ 'https://birthday.example.com/birthday' ,
305+ 'http://www.example.com/' ,
306+ 'https://example.com/addition/action' ,
307+ 'http://example.com/' ,
308+ 'https://bite.example.net/#adjustment' ,
309+ 'https://bite.example.net#adjustment' ,
310+ 'http://www.example.net/badge.php?bedroom=anger' ,
311+ 'https://brass.example.com/?anger=branch&actor=amusement#adjustment' ,
312+ 'https://brass.example.com?anger=branch&actor=amusement#adjustment' ,
313+ 'http://www.example.com/?action=birds&brass=apparatus' ,
314+ 'http://www.example.com?action=birds&brass=apparatus' ,
315+ 'https://example.net/' ,
316+ ];
317+
318+ test ('Insert link in text' , () {
319+ final delta = Delta ()..insert ('\n ' );
320+ final document = Document .fromDelta (delta);
321+
322+ for (final link in validLinks) {
323+ expect (
324+ rule.apply (document, 0 , data: link, len: 0 ),
325+ Delta ()..insert (link, {'link' : link}),
326+ );
327+ }
328+ });
329+ });
289330}
0 commit comments