From 30d83d7c828f7bf5ed285f71e5b4a7bf095002b5 Mon Sep 17 00:00:00 2001 From: Griffin Smith Date: Sun, 13 Jun 2021 23:02:11 -0400 Subject: feat(xanthous): Add a method to get the name for a type of entity I didn't end up using this directly for the thing I was doing, but it still seems generally useful enough that I'm keeping it around for now Change-Id: I05c8902d75845f2230ec2373a9677d61cfaafafd Reviewed-on: https://cl.tvl.fyi/c/depot/+/3206 Reviewed-by: grfn Tested-by: BuildkiteCI --- .../grfn/xanthous/test/Xanthous/Game/StateSpec.hs | 25 ++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 users/grfn/xanthous/test/Xanthous/Game/StateSpec.hs (limited to 'users/grfn/xanthous/test/Xanthous/Game') diff --git a/users/grfn/xanthous/test/Xanthous/Game/StateSpec.hs b/users/grfn/xanthous/test/Xanthous/Game/StateSpec.hs new file mode 100644 index 000000000000..3267d8ef9e9c --- /dev/null +++ b/users/grfn/xanthous/test/Xanthous/Game/StateSpec.hs @@ -0,0 +1,25 @@ +-------------------------------------------------------------------------------- +module Xanthous.Game.StateSpec (main, test) where +-------------------------------------------------------------------------------- +import Test.Prelude +-------------------------------------------------------------------------------- +import Xanthous.Game.State +import Xanthous.Entities.Raws (raws, entityFromRaw) +-------------------------------------------------------------------------------- + +main :: IO () +main = defaultMain test + +test :: TestTree +test = testGroup "Xanthous.Game.StateSpec" + [ testGroup "entityTypeName" + [ testCase "for a creature" $ + let gormlakRaw = raws ^?! ix "gormlak" + creature = entityFromRaw gormlakRaw + in entityTypeName creature @?= "Creature" + , testCase "for an item" $ + let stickRaw = raws ^?! ix "stick" + item = entityFromRaw stickRaw + in entityTypeName item @?= "Item" + ] + ] -- cgit 1.4.1