module Test.Data.Query where import Test.Tasty import Test.Tasty.HUnit import Data.Buuka (BuukaEntry(..), URL(..)) import Data.Functor.Foldable (cata) import Data.Query test_startswith :: Assertion test_startswith = do let entry = BuukaEntry (URL "http://example.com") (Just "foo") cata evaluate (startsWith Url "http://") entry @?= True cata evaluate (startsWith Url "https://") entry @?= False cata evaluate (startsWith Title "foo") entry @?= True cata evaluate (startsWith Title "bar") entry @?= False test_endswith :: Assertion test_endswith = do let entry = BuukaEntry (URL "http://example.com") (Just "foo") cata evaluate (endsWith Url "com") entry @?= True cata evaluate (endsWith Url "fi") entry @?= False cata evaluate (endsWith Title "foo") entry @?= True cata evaluate (endsWith Title "bar") entry @?= False test_and :: Assertion test_and = do let entry = BuukaEntry (URL "http://example.com") (Just "foo") cata evaluate (startsWith Url "http://" .&&. endsWith Url ".com") entry @?= True cata evaluate (startsWith Url "http://" .&&. endsWith Url ".fi") entry @?= False tests :: TestTree tests = testGroup "Data.Query" [ testCase "Queries startsWith" test_startswith , testCase "Queries endsWith" test_endswith , testCase "Queries and" test_and ]