From 5f7f7246a737f464ca79cfb37bc3ccf4cb46c82b Mon Sep 17 00:00:00 2001 From: Edward A Maxedon Date: Tue, 24 Apr 2018 00:18:31 -0400 Subject: [PATCH] more unit tests --- src/test/scala/FilterTests.scala | 63 ++++++++++++++++++++++++++++++++ 1 file changed, 63 insertions(+) diff --git a/src/test/scala/FilterTests.scala b/src/test/scala/FilterTests.scala index aebe2e4..eba124a 100644 --- a/src/test/scala/FilterTests.scala +++ b/src/test/scala/FilterTests.scala @@ -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( """