mercury_ex/test/mercury/utils/text_tests.ex

22 lines
679 B
Elixir

defmodule Mercury.Utils.TextTest do
use ExUnit.Case
doctest Mercury.Utils.Text
test "returns the base url of a paginated url" do
url = "http://example.com/foo/bar/wow-cool/page=10"
cleaned = "http://example.com/foo/bar/wow-cool"
assert article_base_url(url) == cleaned
end
test "returns the same url if url has no pagination info" do
url = "http://example.com/foo/bar/wow-cool/"
cleaned = "http://example.com/foo/bar/wow-cool"
assert article_base_url(url) == cleaned
end
test "normalize spaces" do
assert normalize_spaces(" hello world ") == "hello world"
assert normalize_spaces("\thello\n\tworld\n") == "hello world"
end
end