Update tests

This commit is contained in:
2026-08-21 11:55:27 +03:00
parent efcee8b90a
commit 5954c68682
5 changed files with 31 additions and 16 deletions
+3 -3
View File
@@ -4,14 +4,14 @@ module ConnectionSpec (spec) where
import Data.Aeson (object, (.=))
import Data.Text (Text)
import HomeAssistant.Controller (Service (..))
import HomeAssistant.Controller (Service (..), Target(..))
import HomeAssistant.Runtime.Connection (encodeService)
import Test.Hspec
spec :: Spec
spec = describe "encodeService" $ do
it "encodes a call_service message" $
encodeService 7 (Service "light" "turn_on" Nothing "light.bedroom_masse")
encodeService 7 (Service "light" "turn_on" Nothing [EntityId "light.bedroom_masse"])
`shouldBe` object
[ "id" .= (7 :: Int)
, "type" .= ("call_service" :: Text)
@@ -21,7 +21,7 @@ spec = describe "encodeService" $ do
]
it "includes service_data when present" $
encodeService 8 (Service "light" "turn_on" (Just (object ["brightness" .= (200 :: Int)])) "light.bedroom_masse")
encodeService 8 (Service "light" "turn_on" (Just (object ["brightness" .= (200 :: Int)])) [EntityId "light.bedroom_masse"])
`shouldBe` object
[ "id" .= (8 :: Int)
, "type" .= ("call_service" :: Text)