1{-# LANGUAGE DeriveGeneric #-}
2{-# OPTIONS_GHC -fno-warn-orphans #-}
3module Servant.API.ContentTypesSpec where
5import Control.Applicative
8import qualified Data.Text as TextS
9import qualified Data.Text.Lazy as TextL
14import Servant.API.ContentTypes
17spec = describe "Servant.API.ContentTypes" $ do
19 describe "The JSON Content-Type type" $ do
21 it "has fromByteString reverse toByteString for valid top-level json ([Int]) " $ do
22 let p = Proxy :: Proxy JSON
23 property $ \x -> fromByteString p (toByteString p x) == Right (x::[Int])
25 it "has fromByteString reverse toByteString for valid top-level json " $ do
26 let p = Proxy :: Proxy JSON
27 property $ \x -> fromByteString p (toByteString p x) == Right (x::SomeData)
29 describe "The PlainText Content-Type type" $ do
31 it "has fromByteString reverse toByteString (lazy Text)" $ do
32 let p = Proxy :: Proxy PlainText
33 property $ \x -> fromByteString p (toByteString p x) == Right (x::TextL.Text)
35 it "has fromByteString reverse toByteString (strict Text)" $ do
36 let p = Proxy :: Proxy PlainText
37 property $ \x -> fromByteString p (toByteString p x) == Right (x::TextS.Text)
40data SomeData = SomeData { record1 :: String, record2 :: Int }
41 deriving (Generic, Eq, Show)
43instance FromJSON SomeData
44instance ToJSON SomeData
45instance Arbitrary SomeData where
46 arbitrary = SomeData <$> arbitrary <*> arbitrary
48instance Arbitrary TextL.Text where
49 arbitrary = TextL.pack <$> arbitrary
51instance Arbitrary TextS.Text where
52 arbitrary = TextS.pack <$> arbitrary
keysesc to close
- j k
- move down, up
- enter
- open
- esc
- back, or up a level
- 1 2 3 4
- readme, files, commits, refs
- /
- filter
- y
- copy the clone command
- c
- compare the chosen commit with another (or shift-click both)
- ?
- show or hide this list