module FoundationSpec where

import TestImport

import ModelSpec ()

import qualified Data.CryptoID as CID
import Yesod.EmbeddedStatic

instance Arbitrary (Route Auth) where
  arbitrary = oneof
    [ return CheckR
    , return LoginR
    , return LogoutR
    , PluginR <$> arbitrary <*> arbitrary
    ]

instance Arbitrary (Route EmbeddedStatic) where
  arbitrary = embeddedResourceR <$> arbitrary <*> arbitrary

instance Arbitrary CourseR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary SheetR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary SubmissionR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary MaterialR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary TutorialR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary ExamR where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary (Route UniWorX) where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary a => Arbitrary (CID.CryptoID ns a) where
  arbitrary = CID.CryptoID <$> arbitrary

spec :: Spec
spec = do
  parallel $ 
    lawsCheckHspec (Proxy @(Route UniWorX))
      [ eqLaws, hashableLaws, jsonLaws, jsonKeyLaws, pathPieceLaws ]
