Skip to content

Commit

Permalink
more unit tests
Browse files Browse the repository at this point in the history
  • Loading branch information
edadma committed Apr 24, 2018
1 parent 24ed961 commit 5f7f724
Showing 1 changed file with 63 additions and 0 deletions.
63 changes: 63 additions & 0 deletions src/test/scala/FilterTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -333,11 +333,74 @@ class FilterTests extends FreeSpec with PropertyChecks with Matchers with Testin
) shouldBe "6 195.357"
}

"prepend" in {
test(
"""
|{{ "apples, oranges, and bananas" | prepend: "Some fruit: " }}
""".stripMargin, true
) shouldBe "Some fruit: apples, oranges, and bananas"
test(
"""
|{% assign url = "liquidmarkup.com" %}
|
|{{ "/index.html" | prepend: url }}
""".stripMargin, true
) shouldBe "liquidmarkup.com/index.html"
}

"sort_natural" in {
test( """{{ "zebra, octopus, giraffe, 2, 1, Sally Snake" | split: ", " | sort_natural | join: ", " }}""", false ) shouldBe
"1, 2, giraffe, octopus, Sally Snake, zebra"
}

"split" in {
test(
"""
|{% assign beatles = "John, Paul, George, Ringo" | split: ", " %}
|
|{% for member in beatles %}
| {{ member }}
|{% endfor %}
""".stripMargin, false
).trim shouldBe
"""
|John
|
| Paul
|
| George
|
| Ringo
""".trim.stripMargin
}

"times" in {
test(
"""
|{{ 3 | times: 2 }}
|{{ 183.357 | times: 12 }}
""".stripMargin, true
) shouldBe "6 2200.284"
}

"truncatewords" in {
test(
"""
|{{ "Ground control to Major Tom." | truncatewords: 3 }}
""".stripMargin, true
) shouldBe "Ground control to..."
test(
"""
|{{ "Ground control to Major Tom." | truncatewords: 3, "--" }}
""".stripMargin, true
) shouldBe "Ground control to--"
test(
"""
|{{ "Ground control to Major Tom." | truncatewords: 3, "" }}
""".stripMargin, true
) shouldBe "Ground control to"
}

"uniq" in {
test(
"""
Expand Down

0 comments on commit 5f7f724

Please sign in to comment.