Add tests for mode parameters of slugify Liquid filter

This commit is contained in:
nitoyon 2014-09-14 02:43:17 +09:00
parent 46e76bde3f
commit 3c5e9f5334
2 changed files with 24 additions and 0 deletions

View File

@ -221,6 +221,10 @@ class TestFilters < Test::Unit::TestCase
should "return a slugified string" do
assert_equal "q-bert-says", @filter.slugify(" Q*bert says @!#?@!")
end
should "return a slugified string with mode" do
assert_equal "q-bert-says-@!-@!", @filter.slugify(" Q*bert says @!#?@!", "pretty")
end
end
context "push filter" do

View File

@ -139,6 +139,26 @@ class TestUtils < Test::Unit::TestCase
Utils.slugify(title)
assert_equal "Quick-start guide", title
end
should "not change behaviour if mode is default" do
assert_equal "the-config-yml-file", Utils.slugify("The _config.yml file?", "default")
end
should "not change behaviour if mode is nil" do
assert_equal "the-config-yml-file", Utils.slugify("The _config.yml file?", nil)
end
should "not replace period and underscore if mode is pretty" do
assert_equal "the-_config.yml-file", Utils.slugify("The _config.yml file?", "pretty")
end
should "only replace whitespace if mode is raw" do
assert_equal "the-_config.yml-file?", Utils.slugify("The _config.yml file?", "raw")
end
should "return the given string if mode is none" do
assert_equal "the _config.yml file?", Utils.slugify("The _config.yml file?", "none")
end
end
end