@@ -1,5 +1,6 @@
1−{-# LANGUAGE TypeOperators #-}
1+{-# LANGUAGE DataKinds #-}
22{-# LANGUAGE QuasiQuotes #-}
3+{-# LANGUAGE TypeOperators #-}
34{-# OPTIONS_GHC -fno-warn-orphans #-}
45module Servant.JQuerySpec where
56
@@ -16,14 +17,23 @@ POST /simple String -> Bool
1617GET /has.extension Bool
1718|]
1819
20+type TopLevelRawAPI = "something" :> Get Int
21+ :<|> Raw
22+
1923spec :: Spec
2024spec = describe "Servant.JQuery"
2125 generateJSSpec
2226
2327generateJSSpec :: Spec
24−generateJSSpec = describe "generateJS" $
25− it "should always generate valid javascript" $ do
26− let (postSimple :<|> getHasExtension) = jquery (Proxy :: Proxy TestAPI)
28+generateJSSpec = describe "generateJS" $ do
29+ it "should generate valid javascript" $ do
30+ let (postSimple :<|> getHasExtension ) = jquery (Proxy :: Proxy TestAPI)
2731 parseFromString (generateJS postSimple) `shouldSatisfy` isRight
2832 parseFromString (generateJS getHasExtension) `shouldSatisfy` isRight
33+ print $ generateJS getHasExtension
34+
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
2939