This repository has been archived on 2024-06-09. You can view files and clone it, but cannot push or open issues or pull requests.
linkify/test/builder_test.exs

32 lines
899 B
Elixir
Raw Normal View History

2017-11-17 18:36:37 +00:00
defmodule AutoLinker.BuilderTest do
use ExUnit.Case
doctest AutoLinker.Builder
import AutoLinker.Builder
describe "create_phone_link" do
test "finishes" do
assert create_phone_link([], "", []) == ""
end
2019-02-05 11:22:51 +00:00
2017-11-17 18:36:37 +00:00
test "handles one link" do
phrase = "my exten is x888. Call me."
2019-02-05 11:22:51 +00:00
expected =
~s'my exten is <a href="#" class="phone-number" data-phone="888">x888</a>. Call me.'
2017-11-17 18:36:37 +00:00
assert create_phone_link([["x888", ""]], phrase, []) == expected
end
2019-02-05 11:22:51 +00:00
2017-11-17 18:36:37 +00:00
test "handles multiple links" do
phrase = "555.555.5555 or (555) 888-8888"
2019-02-05 11:22:51 +00:00
expected =
~s'<a href="#" class="phone-number" data-phone="5555555555">555.555.5555</a> or ' <>
~s'<a href="#" class="phone-number" data-phone="5558888888">(555) 888-8888</a>'
2017-11-17 18:36:37 +00:00
assert create_phone_link([["555.555.5555", ""], ["(555) 888-8888"]], phrase, []) == expected
end
end
end