mirror of
https://github.com/danieljharvey/tmux-mate.git
synced 2024-09-11 16:46:40 +03:00
Tests for validation
This commit is contained in:
parent
1b74890edb
commit
24eea83015
@ -6,6 +6,7 @@ import Test.Hspec
|
||||
import Test.QuickCheck
|
||||
import Test.QuickCheck.Monadic
|
||||
import Tests.TmuxMate.Types (Session)
|
||||
import qualified Tests.TmuxMate.Validate as Validate
|
||||
import TmuxMate
|
||||
import TmuxMate.Running
|
||||
import TmuxMate.Types
|
||||
@ -22,6 +23,7 @@ import TmuxMate.Types
|
||||
|
||||
main :: IO ()
|
||||
main = hspec $ do
|
||||
Validate.spec
|
||||
describe "createSession" $ do
|
||||
it "Creates a session if needed" $ do
|
||||
createSession
|
||||
|
62
test/Tests/TmuxMate/Validate.hs
Normal file
62
test/Tests/TmuxMate/Validate.hs
Normal file
@ -0,0 +1,62 @@
|
||||
module Tests.TmuxMate.Validate where
|
||||
|
||||
import Dhall
|
||||
import Dhall.Core (pretty)
|
||||
import Test.Hspec
|
||||
import Test.QuickCheck
|
||||
import Test.QuickCheck.Monadic
|
||||
import Tests.TmuxMate.Types (Session)
|
||||
import TmuxMate
|
||||
import TmuxMate.Running
|
||||
import TmuxMate.Types
|
||||
( Command (..),
|
||||
InTmuxSession (..),
|
||||
Pane (..),
|
||||
PaneCommand (..),
|
||||
PaneTitle (..),
|
||||
Running (..),
|
||||
Session (..),
|
||||
SessionName (..),
|
||||
TmuxCommand (..),
|
||||
ValidationError (..),
|
||||
Window (..),
|
||||
WindowName (..),
|
||||
)
|
||||
import TmuxMate.Validate
|
||||
|
||||
spec :: Spec
|
||||
spec = do
|
||||
describe "Validating Session to VSession" $ do
|
||||
it "Fails on an empty name" $ do
|
||||
let sesh = Session
|
||||
{ sessionTitle = SessionName "",
|
||||
sessionWindows = []
|
||||
}
|
||||
parseSession sesh
|
||||
`shouldBe` Left EmptySessionName
|
||||
it "Fails with no windows" $ do
|
||||
let sesh = Session
|
||||
{ sessionTitle = SessionName "Whoa",
|
||||
sessionWindows = []
|
||||
}
|
||||
parseSession sesh
|
||||
`shouldBe` Left NoWindows
|
||||
it "Fails with empty window name" $ do
|
||||
let sesh = Session
|
||||
{ sessionTitle = SessionName "Whoa",
|
||||
sessionWindows =
|
||||
[ Window
|
||||
{ windowTitle = WindowName "",
|
||||
windowPanes = [Pane {paneCommand = PaneCommand "", paneTitle = PaneTitle ""}]
|
||||
}
|
||||
]
|
||||
}
|
||||
parseSession sesh
|
||||
`shouldBe` Left EmptyWindowName
|
||||
it "Fails with no windows" $ do
|
||||
let sesh = Session
|
||||
{ sessionTitle = SessionName "Whoa",
|
||||
sessionWindows = [Window {windowTitle = WindowName "", windowPanes = []}]
|
||||
}
|
||||
parseSession sesh
|
||||
`shouldBe` Left NoWindows
|
Loading…
Reference in New Issue
Block a user