From e04d4c6eb84d5adfe62b6a538e7c4008974424b2 Mon Sep 17 00:00:00 2001 From: jao Date: Sun, 25 Nov 2018 19:14:03 +0000 Subject: Test namespaces inside Xmobar --- test/Xmobar/Plugins/Monitors/CommonSpec.hs | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) create mode 100644 test/Xmobar/Plugins/Monitors/CommonSpec.hs (limited to 'test/Xmobar/Plugins/Monitors/CommonSpec.hs') diff --git a/test/Xmobar/Plugins/Monitors/CommonSpec.hs b/test/Xmobar/Plugins/Monitors/CommonSpec.hs new file mode 100644 index 0000000..84cfbf3 --- /dev/null +++ b/test/Xmobar/Plugins/Monitors/CommonSpec.hs @@ -0,0 +1,29 @@ +module Xmobar.Plugins.Monitors.CommonSpec + ( main + , spec + ) where + +import Test.Hspec +import Xmobar.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 -- cgit v1.2.3