@@ -14,6 +14,7 @@ import Test.Hspec
15import Servant.API
15import Servant.API
16import Servant.JQuery
16import Servant.JQuery
17+import Servant.JQuerySpec.CustomHeaders
18type TestAPI = [sitemap|
19type TestAPI = [sitemap|
19POST /simple String -> Bool
20POST /simple String -> Bool
@@ -26,9 +27,15 @@ type TopLevelRawAPI = "something" :> Get Int
26type HeaderHandlingAPI = "something" :> Header "Foo" String
27type HeaderHandlingAPI = "something" :> Header "Foo" String
27 :> Get Int
28 :> Get Int
30+type CustomAuthAPI = "something" :> Authorization "Basic" String
29headerHandlingProxy :: Proxy HeaderHandlingAPI
33headerHandlingProxy :: Proxy HeaderHandlingAPI
30headerHandlingProxy = Proxy
34headerHandlingProxy = Proxy
36+customAuthProxy :: Proxy CustomAuthAPI
37+customAuthProxy = Proxy
32spec :: Spec
39spec :: Spec
33spec = describe "Servant.JQuery"
40spec = describe "Servant.JQuery"
34 generateJSSpec
41 generateJSSpec
@@ -53,3 +60,10 @@ generateJSSpec = describe "generateJS" $ do
53 jsText `shouldContain` "headerFoo"
60 jsText `shouldContain` "headerFoo"
54 jsText `shouldContain` "headers: { \"Foo\": headerFoo }\n"
61 jsText `shouldContain` "headers: { \"Foo\": headerFoo }\n"
63+ it "should handle complex HTTP headers" $ do
64+ let jsText = generateJS $ jquery customAuthProxy
66+ parseFromString jsText `shouldSatisfy` isRight
67+ jsText `shouldContain` "headerAuthorization"
68+ jsText `shouldContain` "headers: { \"Authorization\": \"Basic \" + headerAuthorization }\n"