diff --git a/servant-js/src/Servant/JS.hs b/servant-js/src/Servant/JS.hs index b2e63ca3..691a21ff 100644 --- a/servant-js/src/Servant/JS.hs +++ b/servant-js/src/Servant/JS.hs @@ -110,6 +110,7 @@ module Servant.JS , -- * Misc. listFromAPI , javascript + , LangJS , GenerateList(..) ) where diff --git a/servant-js/test/Servant/JSSpec.hs b/servant-js/test/Servant/JSSpec.hs index 5e692e59..ae3039ab 100644 --- a/servant-js/test/Servant/JSSpec.hs +++ b/servant-js/test/Servant/JSSpec.hs @@ -98,16 +98,17 @@ a `shouldNotContain` b = shouldNotSatisfy a (T.isInfixOf b) axiosSpec :: Spec axiosSpec = describe specLabel $ do + let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI) it "should add withCredentials when needed" $ do - let jsText = genJS withCredOpts $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS withCredOpts $ reqList output jsText jsText `shouldContain` "withCredentials: true" it "should add xsrfCookieName when needed" $ do - let jsText = genJS cookieOpts $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS cookieOpts $ reqList output jsText jsText `shouldContain` ("xsrfCookieName: 'MyXSRFcookie'") it "should add withCredentials when needed" $ do - let jsText = genJS headerOpts $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS headerOpts $ reqList output jsText jsText `shouldContain` ("xsrfHeaderName: 'MyXSRFheader'") where @@ -121,18 +122,19 @@ axiosSpec = describe specLabel $ do angularSpec :: TestNames -> Spec angularSpec test = describe specLabel $ do + let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI) it "should implement a service globally" $ do - let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS reqList output jsText jsText `shouldContain` (".service('" <> testName <> "'") it "should depend on $http service globally" $ do - let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS reqList output jsText jsText `shouldContain` ("('" <> testName <> "', function($http) {") it "should not depend on $http service in handlers" $ do - let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) + let jsText = genJS reqList output jsText jsText `shouldNotContain` "getsomething($http, " where