git.iko.soy/typeable/servant
on master help sign in
Merge pull request #3 from haskell-servant/jkarni/issue1

Fix dot in function name issue.

commitfb153d4e088694d36ea878dc154ad456386bfc68 authorAlp Mestanogullari <alpmestan@gmail.com> dateWed 24 Dec 2014, 14:02 (12 years ago) parentd10698958b27cd
4 files changed+46−2
servant-jquery.cabal+14−1 src/Servant/JQuery/Internal.hs+1−1 test/Servant/JQuerySpec.hs+29 test/Spec.hs+2
servant-jquery.cabal+14−1
@@ -37,7 +37,7 @@ executable counter
3737 main-is: counter.hs
3838 ghc-options: -O2 -Wall
3939 hs-source-dirs: examples
40−
40+
4141 if flag(example)
4242 buildable: True
4343 else
@@ -54,3 +54,16 @@ executable counter
5454 , transformers
5555 , warp
5656 default-language: Haskell2010
57+
58+test-suite spec
59+ type: exitcode-stdio-1.0
60+ hs-source-dirs: test
61+ ghc-options: -Wall
62+ main-is: Spec.hs
63+ build-depends:
64+ base == 4.*
65+ , servant-jquery
66+ , servant
67+ , hspec >= 2.0
68+ , language-ecmascript == 0.16.*
69+ default-language: Haskell2010
src/Servant/JQuery/Internal.hs+1−1
@@ -214,4 +214,4 @@ instance (KnownSymbol path, HasJQ sublayout)
214214 req & reqUrl.path <>~ [Static str]
215215 & funcName %~ (str <>)
216216
217− where str = symbolVal (Proxy :: Proxy path)
217+ where str = map (\c -> if c == '.' then '_' else c) $ symbolVal (Proxy :: Proxy path)
test/Servant/JQuerySpec.hsnew file+29
@@ -0,0 +1,29 @@
1+{-# LANGUAGE TypeOperators #-}
2+{-# LANGUAGE QuasiQuotes #-}
3+{-# OPTIONS_GHC -fno-warn-orphans #-}
4+module Servant.JQuerySpec where
5+
6+import Data.Either (isRight)
7+import Data.Proxy
8+import Language.ECMAScript3.Parser (parseFromString)
9+import Test.Hspec
10+
11+import Servant.API
12+import Servant.JQuery
13+
14+type TestAPI = [sitemap|
15+POST /simple String -> Bool
16+GET /has.extension Bool
17+|]
18+
19+spec :: Spec
20+spec = describe "Servant.JQuery"
21+ generateJSSpec
22+
23+generateJSSpec :: Spec
24+generateJSSpec = describe "generateJS" $
25+ it "should always generate valid javascript" $ do
26+ let (postSimple :<|> getHasExtension) = jquery (Proxy :: Proxy TestAPI)
27+ parseFromString (generateJS postSimple) `shouldSatisfy` isRight
28+ parseFromString (generateJS getHasExtension) `shouldSatisfy` isRight
29+
test/Spec.hsnew file+2
@@ -0,0 +1,2 @@
1+{-# OPTIONS_GHC -F -pgmF hspec-discover #-}
2+