From 17126aa662de56f93f661e7767f7148e5b753234 Mon Sep 17 00:00:00 2001 From: Mark Felder Date: Thu, 19 Nov 2020 18:29:41 +0000 Subject: [PATCH] Move tests under correct group, add test for URLs with IPv4 for domain --- test/linkify_test.exs | 69 ++++++++++++++++++++++++++----------------- 1 file changed, 42 insertions(+), 27 deletions(-) diff --git a/test/linkify_test.exs b/test/linkify_test.exs index bdaffc1..164a34e 100644 --- a/test/linkify_test.exs +++ b/test/linkify_test.exs @@ -489,9 +489,49 @@ defmodule LinkifyTest do test "turn urls with schema into urls" do text = "📌https://google.com" + expected = "📌https://google.com" assert Linkify.link(text, rel: false) == expected + + text = "http://www.cs.vu.nl/~ast/intel/" + + expected = "http://www.cs.vu.nl/~ast/intel/" + + assert Linkify.link(text) == expected + + text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087" + + expected = + "https://forum.zdoom.org/viewtopic.php?f=44&t=57087" + + assert Linkify.link(text) == expected + + text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul" + + expected = + "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul" + + assert Linkify.link(text) == expected + + text = "https://en.wikipedia.org/wiki/Duff's_device" + + expected = + "https://en.wikipedia.org/wiki/Duff's_device" + + assert Linkify.link(text) == expected + + text = "https://1.1.1.1/" + + expected = "https://1.1.1.1/" + + assert Linkify.link(text) == expected + + text = "https://1.1.1.1:8080/" + + expected = "https://1.1.1.1:8080/" + + assert Linkify.link(text) == expected end test "strip prefix" do @@ -525,35 +565,10 @@ defmodule LinkifyTest do assert Linkify.link(text, new_window: true) == expected text = "@username" + expected = "@username" + assert Linkify.link(text, new_window: true) == expected - - text = "http://www.cs.vu.nl/~ast/intel/" - - expected = "http://www.cs.vu.nl/~ast/intel/" - - assert Linkify.link(text) == expected - - text = "https://forum.zdoom.org/viewtopic.php?f=44&t=57087" - - expected = - "https://forum.zdoom.org/viewtopic.php?f=44&t=57087" - - assert Linkify.link(text) == expected - - text = "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul" - - expected = - "https://en.wikipedia.org/wiki/Sophia_(Gnosticism)#Mythos_of_the_soul" - - assert Linkify.link(text) == expected - - text = "https://en.wikipedia.org/wiki/Duff's_device" - - expected = - "https://en.wikipedia.org/wiki/Duff's_device" - - assert Linkify.link(text) == expected end end