on master help sign in
Update tests for Axios
commit3ff1f5c95359b9c4124db2377fbdea860c1762c1 authorFreezeboy <freezeboy@users.noreply.github.com> dateMon 27 Jul 2015, 16:49 (11 years ago) parent2e2eac6
2 files changed+10−3
servant-js/src/Servant/JS/Axios.hs+4−2 servant-js/test/Servant/JSSpec.hs+6−1
servant-js/src/Servant/JS/Axios.hs+4−2
@@ -24,7 +24,9 @@ generateAxiosJSWith :: CommonGeneratorOptions -> AjaxReq -> String
2424generateAxiosJSWith opts req = "\n" <>
2525 fname <> " = function(" <> argsStr <> ")\n"
2626 <> "{\n"
27− <> " return axios." <> method <> "(" <> url <> ",\n"
27+ <> " return axios(" <> url <> ",\n"
28+ <> " {\n"
29+ <> " method: '" <> method <> "'\n"
2830 <> dataBody
2931 <> reqheaders
3032 <> " });\n"
@@ -76,7 +78,7 @@ generateAxiosJSWith opts req = "\n" <>
7678 method = map toLower $ req ^. reqMethod
7779 url = if url' == "'" then "'/'" else url'
7880 url' = "'"
79− ++ urlPrefix opts
81+ -- ++ urlPrefix opts
8082 ++ urlArgs
8183 ++ queryArgs
8284
servant-js/test/Servant/JSSpec.hs+6−1
@@ -17,6 +17,7 @@ import Servant.JS
1717import qualified Servant.JS.Vanilla as JS
1818import qualified Servant.JS.JQuery as JQ
1919import qualified Servant.JS.Angular as NG
20+import qualified Servant.JS.Axios as AX
2021import Servant.JSSpec.CustomHeaders
2122
2223type TestAPI = "simple" :> ReqBody '[JSON,FormUrlEncoded] String :> Post '[JSON] Bool
@@ -55,6 +56,8 @@ data TestNames = Vanilla
5556 | JQueryCustom
5657 | Angular
5758 | AngularCustom
59+ | Axios
60+ | AxiosCustom
5861 deriving (Show, Eq)
5962
6063customOptions :: CommonGeneratorOptions
@@ -71,6 +74,8 @@ spec = describe "Servant.JQuery" $ do
7174 generateJSSpec JQueryCustom (JQ.generateJQueryJSWith customOptions)
7275 generateJSSpec Angular (NG.generateAngularJS NG.defAngularOptions)
7376 generateJSSpec AngularCustom (NG.generateAngularJSWith NG.defAngularOptions customOptions)
77+ generateJSSpec Axios AX.generateAxiosJS
78+ generateJSSpec AxiosCustom (AX.generateAxiosJSWith customOptions)
7479
7580 angularSpec Angular
7681 angularSpec AngularCustom
@@ -143,7 +148,7 @@ generateJSSpec n gen = describe specLabel $ do
143148 parseFromString jsStr `shouldSatisfy` isRight
144149 where
145150 specLabel = "generateJS(" ++ (show n) ++ ")"
146− output _ = return ()
151+ output = putStrLn
147152 genJS req = gen req
148153 header :: TestNames -> String -> String -> String
149154 header v headerName headerValue