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 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48
|
module ItemDescriptionUnitTests (itemDescriptionUnitTests) where
import Prelude ()
import Game.LambdaHack.Core.Prelude
import qualified Data.EnumMap.Strict as EM
import Test.Tasty
import Test.Tasty.HUnit
import Game.LambdaHack.Client.UI.ItemDescription
(viewItem, viewItemBenefitColored)
import Game.LambdaHack.Common.Item
import Game.LambdaHack.Common.ItemAspect (emptyAspectRecord)
import Game.LambdaHack.Common.Kind (emptyMultiGroupItem)
import Game.LambdaHack.Content.ItemKind (ItemKind (isymbol))
import Game.LambdaHack.Definition.Color
(Color (BrGreen, BrRed, Green), attrChar2ToW32)
import Game.LambdaHack.Definition.Flavour (zipPlain)
import UnitTestHelpers (stubItem)
itemDescriptionUnitTests :: TestTree
itemDescriptionUnitTests = testGroup "itemDescriptionUnitTests" $
let testItemFull = ItemFull
{ itemBase = stubItem
{
jkind = IdentityObvious (toEnum 667)
, jflavour = head $ zipPlain [Green]
}
, itemKindId = toEnum 667
, itemKind = emptyMultiGroupItem
, itemDisco = ItemDiscoFull emptyAspectRecord
, itemSuspect = True
}
in
[ testCase "testItem_viewItem_Blackx" $
viewItem testItemFull {itemKind = emptyMultiGroupItem {isymbol = 'x'}}
@?= attrChar2ToW32 Green 'x'
, testCase "testItem_viewItem_Black!" $
viewItem testItemFull {itemKind = emptyMultiGroupItem {isymbol = '!'}}
@?= attrChar2ToW32 Green '!'
, testCase "testItem_viewItemBenefitColored_isEquip_Greenx" $
viewItemBenefitColored (EM.singleton (toEnum 42) (Benefit True 0 0 0 0)) (toEnum 42) testItemFull {itemKind = emptyMultiGroupItem {isymbol = 'x'}}
@?= attrChar2ToW32 BrGreen 'x'
, testCase "testItem_viewItemBenefitColored_isNotEquip_Redx" $
viewItemBenefitColored (EM.singleton (toEnum 42) (Benefit False 0 0 0 0)) (toEnum 42) testItemFull {itemKind = emptyMultiGroupItem {isymbol = 'x'}}
@?= attrChar2ToW32 BrRed 'x'
]
|