summaryrefslogtreecommitdiffhomepage
path: root/test/Plugins/Monitors
diff options
context:
space:
mode:
authorOlivier Schneider <olivier.schneider@kolabnow.com>2018-03-03 15:50:02 +0100
committerOlivier Schneider <olivier.schneider@kolabnow.com>2018-03-07 20:39:21 +0100
commitae37e13986b45150f69d7cfa2555cf6b22ccc3c9 (patch)
treebd6780a415024ad152ba31c385d1d3d3036a51c4 /test/Plugins/Monitors
parent2e28ddc842efeb7835ebfc04bb346c2faae54873 (diff)
downloadxmobar-ae37e13986b45150f69d7cfa2555cf6b22ccc3c9.tar.gz
xmobar-ae37e13986b45150f69d7cfa2555cf6b22ccc3c9.tar.bz2
Add ellipsis option for Monitor's fields and total text
Diffstat (limited to 'test/Plugins/Monitors')
-rw-r--r--test/Plugins/Monitors/CommonSpec.hs29
1 files changed, 29 insertions, 0 deletions
diff --git a/test/Plugins/Monitors/CommonSpec.hs b/test/Plugins/Monitors/CommonSpec.hs
new file mode 100644
index 0000000..847368c
--- /dev/null
+++ b/test/Plugins/Monitors/CommonSpec.hs
@@ -0,0 +1,29 @@
+module Plugins.Monitors.CommonSpec
+ ( main
+ , spec
+ ) where
+
+import Test.Hspec
+import Plugins.Monitors.Common
+
+main :: IO ()
+main = hspec spec
+
+spec :: Spec
+spec =
+ describe "Common.padString" $ do
+ it "returns given string when called with default values" $
+ do padString 0 0 "" False "" "test" `shouldBe` "test"
+
+ it "truncates to max width" $ do
+ let maxw = 3
+ givenStr = "mylongstr"
+ expectedStr = take maxw givenStr
+ padString 0 maxw "" False "" givenStr `shouldBe` expectedStr
+
+ it "truncates to max width and concatenate with ellipsis" $ do
+ let maxw = 3
+ givenStr = "mylongstr"
+ ellipsis = "..."
+ expectedStr = (++ ellipsis) . take 3 $ givenStr
+ padString 0 maxw "" False ellipsis givenStr `shouldBe` expectedStr