about summary refs log tree commit diff
path: root/users/grfn/xanthous/test/Xanthous/Entities/RawsSpec.hs
blob: b6c80be51be7a4748b7ec1f6703e371ef094c1bb (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
-- |

module Xanthous.Entities.RawsSpec (main, test) where

import Test.Prelude
import Xanthous.Entities.Raws
import Xanthous.Entities.RawTypes
       (_Creature, entityName, generateParams, HasEquippedItem (equippedItem))

main :: IO ()
main = defaultMain test

test :: TestTree
test = testGroup "Xanthous.Entities.Raws"
  [ testGroup "raws"
    [ testCase "are all valid" $ raws `deepseq` pure ()
    , testCase "all CreatureEquippedItems reference existent entity names" $
      let notFound
            = raws
              ^.. folded
              . _Creature
              . generateParams
              . _Just
              . equippedItem
              . _Just
              . entityName
              . filtered (isNothing . raw)
      in null notFound @? ("Some entities weren't found: " <> show notFound)
    ]
  ]