{-# LANGUAGE ScopedTypeVariables #-} {-# LANGUAGE OverloadedStrings #-} module CaTextSpec where import Data.Text (Text) import qualified Data.Text as T import Faker hiding (defaultFakerSettings) import qualified Faker.Color as CL import Faker.Combinators (listOf) import qualified Faker.Name as NA import Test.Hspec import TestImport isText :: Text -> Bool isText x = T.length x >= 1 isTexts :: [Text] -> Bool isTexts xs = and $ map isText xs fakerSettings :: FakerSettings fakerSettings = setLocale "ca" defaultFakerSettings verifyFakes :: [Fake Text] -> IO [Bool] verifyFakes funs = do let fs :: [IO Text] = map (generateWithSettings fakerSettings) funs gs :: [IO Bool] = map (\f -> isText <$> f) fs sequence gs verifyDistributeFakes :: [Fake Text] -> IO [Bool] verifyDistributeFakes funs = do let fs :: [IO [Text]] = map (generateWithSettings fakerSettings) $ map (listOf 100) funs gs :: [IO Bool] = map (\f -> isTexts <$> f) fs sequence gs spec :: Spec spec = do describe "TextSpec" $ do it "ca CAT Locale" $ do let functions :: [Fake Text] = [NA.firstName, NA.lastName, NA.name, NA.nameWithMiddle, CL.name] bools <- verifyDistributeFakes functions (and bools) `shouldBe` True