Update tests for Axios
This commit is contained in:
parent
2e2eac6543
commit
3ff1f5c953
2 changed files with 10 additions and 3 deletions
|
@ -24,7 +24,9 @@ generateAxiosJSWith :: CommonGeneratorOptions -> AjaxReq -> String
|
|||
generateAxiosJSWith opts req = "\n" <>
|
||||
fname <> " = function(" <> argsStr <> ")\n"
|
||||
<> "{\n"
|
||||
<> " return axios." <> method <> "(" <> url <> ",\n"
|
||||
<> " return axios(" <> url <> ",\n"
|
||||
<> " {\n"
|
||||
<> " method: '" <> method <> "'\n"
|
||||
<> dataBody
|
||||
<> reqheaders
|
||||
<> " });\n"
|
||||
|
@ -76,7 +78,7 @@ generateAxiosJSWith opts req = "\n" <>
|
|||
method = map toLower $ req ^. reqMethod
|
||||
url = if url' == "'" then "'/'" else url'
|
||||
url' = "'"
|
||||
++ urlPrefix opts
|
||||
-- ++ urlPrefix opts
|
||||
++ urlArgs
|
||||
++ queryArgs
|
||||
|
||||
|
|
|
@ -17,6 +17,7 @@ import Servant.JS
|
|||
import qualified Servant.JS.Vanilla as JS
|
||||
import qualified Servant.JS.JQuery as JQ
|
||||
import qualified Servant.JS.Angular as NG
|
||||
import qualified Servant.JS.Axios as AX
|
||||
import Servant.JSSpec.CustomHeaders
|
||||
|
||||
type TestAPI = "simple" :> ReqBody '[JSON,FormUrlEncoded] String :> Post '[JSON] Bool
|
||||
|
@ -55,6 +56,8 @@ data TestNames = Vanilla
|
|||
| JQueryCustom
|
||||
| Angular
|
||||
| AngularCustom
|
||||
| Axios
|
||||
| AxiosCustom
|
||||
deriving (Show, Eq)
|
||||
|
||||
customOptions :: CommonGeneratorOptions
|
||||
|
@ -71,6 +74,8 @@ spec = describe "Servant.JQuery" $ do
|
|||
generateJSSpec JQueryCustom (JQ.generateJQueryJSWith customOptions)
|
||||
generateJSSpec Angular (NG.generateAngularJS NG.defAngularOptions)
|
||||
generateJSSpec AngularCustom (NG.generateAngularJSWith NG.defAngularOptions customOptions)
|
||||
generateJSSpec Axios AX.generateAxiosJS
|
||||
generateJSSpec AxiosCustom (AX.generateAxiosJSWith customOptions)
|
||||
|
||||
angularSpec Angular
|
||||
angularSpec AngularCustom
|
||||
|
@ -143,7 +148,7 @@ generateJSSpec n gen = describe specLabel $ do
|
|||
parseFromString jsStr `shouldSatisfy` isRight
|
||||
where
|
||||
specLabel = "generateJS(" ++ (show n) ++ ")"
|
||||
output _ = return ()
|
||||
output = putStrLn
|
||||
genJS req = gen req
|
||||
header :: TestNames -> String -> String -> String
|
||||
header v headerName headerValue
|
||||
|
|
Loading…
Reference in a new issue