module TTT.ConfigSpec where

import Test.Hspec

import TTT.GameState (initialState)
import TTT.Config (Config(..), PlayerType(..), configurePlayerTypes, configureGameState)

spec = describe "Config" $ do
    context "configuring player types" $ do
        it "will return a Human vs. Computer configuration" $ do
            configurePlayerTypes "1" `shouldBe` Just [Human, Computer]

        it "will return a Computer vs. Human configuration" $ do
            configurePlayerTypes "2" `shouldBe` Just [Computer, Human]

        it "will return a Human vs. Human configuration" $ do
            configurePlayerTypes "3" `shouldBe` Just [Human, Human]

        it "won't return a configuration if given invalid input" $ do
            configurePlayerTypes "banana" `shouldBe` Nothing


    context "configuring the board" $ do
        it "will return a 3x3 configuration" $ do
            configureGameState "1" `shouldBe` Just (initialState 3)

        it "will return a 4x4 configuration" $ do
            configureGameState "2" `shouldBe` Just (initialState 4)

        it "won't return a valid configuration if given invalid input" $ do
            configureGameState "banana" `shouldBe` Nothing
