Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

More testing...

  • Loading branch information...
commit b069b6d3c99d9b006d1ccec572c88901cc60c49b 1 parent da5fd97
@jaspervdj jaspervdj authored
View
11 tests/Text/Digestive/Common/Tests.hs
@@ -6,6 +6,8 @@ import Control.Applicative ((<$>), (<*>))
import Test.Framework (Test)
import Test.Framework.Providers.QuickCheck2 (testProperty)
+import Test.Framework.Providers.HUnit (testCase)
+import Test.HUnit (Assertion, (@?))
import Text.Digestive.Tests.Util
import Text.Digestive.Types
@@ -14,6 +16,7 @@ import Text.Digestive.Common
tests :: [Test]
tests = [ testProperty "pass through" passThrough
, testProperty "compose" compose
+ , testCase "label ID" labelId
]
-- Build a test case: give a string as only input, run it through a form, the
@@ -40,3 +43,11 @@ compose a b = unId $ do
form = (,) <$> inputRead view' "read error" Nothing
<*> inputString view' Nothing
environment aId bId = fromList [(aId, show a), (bId, b)]
+
+-- Check that the label ID stays the same
+labelId :: Assertion
+labelId = unId $ do
+ [l1, l2, l3] <- viewForm form "form"
+ return $ l1 == l2 && l2 == l3 @? "ID's should be the same"
+ where
+ form = label return ++> inputString (\x _ -> [x]) Nothing <++ label return
View
14 tests/Text/Digestive/Types/Tests.hs
@@ -9,10 +9,22 @@ import Text.Digestive.Tests.Util
import Text.Digestive.Types
tests :: [Test]
-tests = [ testProperty "viewOnly" viewOnly
+tests = [ testProperty "view only" viewOnly
+ , testProperty "left append" leftAppend
+ , testProperty "right append" rightAppend
]
-- If we only have a view as form, that should exactly be the view we get
-- back...
viewOnly :: String -> Bool
viewOnly str = str == unId (viewForm (view str) "form")
+
+-- Check that the views get appended...
+leftAppend :: Form Id i e String Int -> Form Id i e String () -> Bool
+leftAppend f1 f2 = unId (viewForm f1 "form") ++ unId (viewForm f2 "form") ==
+ unId (viewForm (f1 <++ f2) "form")
+
+-- Same for right append
+rightAppend :: Form Id i e String () -> Form Id i e String Int -> Bool
+rightAppend f1 f2 = unId (viewForm f1 "form") ++ unId (viewForm f2 "form") ==
+ unId (viewForm (f1 ++> f2) "form")
Please sign in to comment.
Something went wrong with that request. Please try again.