module MailSpec where

import TestImport
import Utils.DateTimeSpec ()

import Mail

instance Arbitrary MailSmtpData where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary MailLanguages where
  arbitrary = fmap MailLanguages $ shuffle =<< sublistOf (toList appLanguages)
  shrink = genericShrink

instance Arbitrary MailContext where
  arbitrary = genericArbitrary
  shrink = genericShrink

instance Arbitrary VerpMode where
  arbitrary = genericArbitrary
  shrink = genericShrink

spec :: Spec
spec = do
  parallel $ do
    lawsCheckHspec (Proxy @MailSmtpData)
      [ eqLaws, ordLaws, showReadLaws, monoidLaws ]
    lawsCheckHspec (Proxy @MailLanguages)
      [ eqLaws, ordLaws, showReadLaws, isListLaws, jsonLaws, hashableLaws ]
    lawsCheckHspec (Proxy @MailContext)
      [ eqLaws, ordLaws, showReadLaws, jsonLaws, hashableLaws ]
    lawsCheckHspec (Proxy @VerpMode)
      [ eqLaws, showReadLaws, jsonLaws ]
