Merge pull request #230 from frasertweedale/test/list-initial-selection

Add test for List initial selection
This commit is contained in:
Jonathan Daugherty 2019-05-04 09:07:24 -07:00 committed by GitHub
commit 5c1596db00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -98,6 +98,13 @@ applyListOps
=> (op a -> List n a -> List n a) -> t (op a) -> List n a -> List n a
applyListOps f = appEndo . foldMap (Endo . f)
-- | Initial selection is always 0 (or Nothing for empty list)
prop_initialSelection :: [a] -> Bool
prop_initialSelection xs =
list () (V.fromList xs) 1 ^. listSelectedL ==
if null xs then Nothing else Just 0
-- list operations keep the selected index in bounds
prop_listOpsMaintainSelectedValid
:: (Eq a) => [ListOp a] -> List n a -> Bool