@@ -1,5 +1,6 @@
1−{-# LANGUAGE TypeOperators #-}
1+{-# LANGUAGE DataKinds #-}
2{-# LANGUAGE QuasiQuotes #-}
2{-# LANGUAGE QuasiQuotes #-}
3+{-# LANGUAGE TypeOperators #-}
3{-# OPTIONS_GHC -fno-warn-orphans #-}
4{-# OPTIONS_GHC -fno-warn-orphans #-}
4module Servant.JQuerySpec where
5module Servant.JQuerySpec where
@@ -16,14 +17,23 @@ POST /simple String -> Bool
16GET /has.extension Bool
17GET /has.extension Bool
20+type TopLevelRawAPI = "something" :> Get Int
19spec :: Spec
23spec :: Spec
20spec = describe "Servant.JQuery"
24spec = describe "Servant.JQuery"
21 generateJSSpec
25 generateJSSpec
23generateJSSpec :: Spec
27generateJSSpec :: Spec
24−generateJSSpec = describe "generateJS" $
28+generateJSSpec = describe "generateJS" $ do
25− it "should always generate valid javascript" $ do
29+ it "should generate valid javascript" $ do
26− let (postSimple :<|> getHasExtension) = jquery (Proxy :: Proxy TestAPI)
30+ let (postSimple :<|> getHasExtension ) = jquery (Proxy :: Proxy TestAPI)
27 parseFromString (generateJS postSimple) `shouldSatisfy` isRight
31 parseFromString (generateJS postSimple) `shouldSatisfy` isRight
28 parseFromString (generateJS getHasExtension) `shouldSatisfy` isRight
32 parseFromString (generateJS getHasExtension) `shouldSatisfy` isRight
33+ print $ generateJS getHasExtension
35+ it "should use non-empty function names" $ do
36+ let (_ :<|> topLevel) = jquery (Proxy :: Proxy TopLevelRawAPI)
37+ print $ generateJS $ topLevel "GET"
38+ parseFromString (generateJS $ topLevel "GET") `shouldSatisfy` isRight