From 73945481190210fedb0c6f5df63bb77133f6ec83 Mon Sep 17 00:00:00 2001 From: Egor Kislitsyn Date: Tue, 9 Apr 2019 15:03:39 +0700 Subject: [PATCH] =?UTF-8?q?test=20coverage=20100%!=20=F0=9F=8E=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- test/auto_linker_test.exs | 18 ++++++++++++++++++ test/builder_test.exs | 14 ++++++++++++-- test/parser_test.exs | 7 ++++++- 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/test/auto_linker_test.exs b/test/auto_linker_test.exs index 46be2fd..0478c57 100644 --- a/test/auto_linker_test.exs +++ b/test/auto_linker_test.exs @@ -61,6 +61,24 @@ defmodule AutoLinkerTest do new_window: false, rel: custom_rel ) == expected + + text = "google.com" + + expected = "google.com" + + custom_rel = fn _ -> nil end + + assert AutoLinker.link(text, + class: false, + new_window: false, + rel: custom_rel + ) == expected + end + + test "link_map/2" do + assert AutoLinker.link_map("google.com", []) == + {"google.com", + []} end describe "custom handlers" do diff --git a/test/builder_test.exs b/test/builder_test.exs index 0742bd6..e20f6ea 100644 --- a/test/builder_test.exs +++ b/test/builder_test.exs @@ -17,6 +17,16 @@ defmodule AutoLinker.BuilderTest do "text" assert create_link("text", %{rel: "me"}) == expected + + expected = "t..." + + assert create_link("text", %{truncate: 3, rel: false}) == expected + + expected = "text" + assert create_link("text", %{truncate: 2, rel: false}) == expected + + expected = "http://text" + assert create_link("http://text", %{rel: false, strip_prefix: false}) == expected end test "create_markdown_links/2" do @@ -52,9 +62,9 @@ defmodule AutoLinker.BuilderTest do phrase = "my exten is x888. Call me." expected = - ~s'my exten is x888. Call me.' + ~s'my exten is x888. Call me.' - assert create_phone_link([["x888", ""]], phrase, []) == expected + assert create_phone_link([["x888", ""]], phrase, attributes: [test: "test"]) == expected end test "handles multiple links" do diff --git a/test/parser_test.exs b/test/parser_test.exs index a5f0c29..da68edc 100644 --- a/test/parser_test.exs +++ b/test/parser_test.exs @@ -85,7 +85,7 @@ defmodule AutoLinker.ParserTest do expected = "
google.com
" - assert parse(text, class: false, rel: false, new_window: false) == expected + assert parse(text, class: false, rel: false, new_window: false, phone: false) == expected text = "Check out
google.com
" @@ -105,6 +105,11 @@ defmodule AutoLinker.ParserTest do text = "```Check out
google.com
```" assert parse(text, exclude_patterns: ["```"]) == text end + + test "do not link urls" do + text = "google.com" + assert parse(text, url: false, phone: true) == text + end end def valid_number?([list], number) do