@@ -14,6 +14,7 @@ import Test.Hspec
1414
1515import Servant.API
1616import Servant.JQuery
17+import Servant.JQuerySpec.CustomHeaders
1718
1819type TestAPI = [sitemap|
1920POST /simple String -> Bool
@@ -26,9 +27,15 @@ type TopLevelRawAPI = "something" :> Get Int
2627type HeaderHandlingAPI = "something" :> Header "Foo" String
2728 :> Get Int
2829
30+type CustomAuthAPI = "something" :> Authorization "Basic" String
31+ :> Get Int
32+
2933headerHandlingProxy :: Proxy HeaderHandlingAPI
3034headerHandlingProxy = Proxy
3135
36+customAuthProxy :: Proxy CustomAuthAPI
37+customAuthProxy = Proxy
38+
3239spec :: Spec
3340spec = describe "Servant.JQuery"
3441 generateJSSpec
@@ -53,3 +60,10 @@ generateJSSpec = describe "generateJS" $ do
5360 jsText `shouldContain` "headerFoo"
5461 jsText `shouldContain` "headers: { \"Foo\": headerFoo }\n"
5562
63+ it "should handle complex HTTP headers" $ do
64+ let jsText = generateJS $ jquery customAuthProxy
65+ print jsText
66+ parseFromString jsText `shouldSatisfy` isRight
67+ jsText `shouldContain` "headerAuthorization"
68+ jsText `shouldContain` "headers: { \"Authorization\": \"Basic \" + headerAuthorization }\n"
69+