Fix broken servant-js tests.

This commit is contained in:
Maksymilian Owsianny 2015-12-02 13:22:01 +00:00
parent b6ee20dfe0
commit 0c0c382ae6
2 changed files with 9 additions and 6 deletions

View file

@ -110,6 +110,7 @@ module Servant.JS
, -- * Misc. , -- * Misc.
listFromAPI listFromAPI
, javascript , javascript
, LangJS
, GenerateList(..) , GenerateList(..)
) where ) where

View file

@ -98,16 +98,17 @@ a `shouldNotContain` b = shouldNotSatisfy a (T.isInfixOf b)
axiosSpec :: Spec axiosSpec :: Spec
axiosSpec = describe specLabel $ do axiosSpec = describe specLabel $ do
let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI)
it "should add withCredentials when needed" $ do it "should add withCredentials when needed" $ do
let jsText = genJS withCredOpts $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS withCredOpts $ reqList
output jsText output jsText
jsText `shouldContain` "withCredentials: true" jsText `shouldContain` "withCredentials: true"
it "should add xsrfCookieName when needed" $ do it "should add xsrfCookieName when needed" $ do
let jsText = genJS cookieOpts $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS cookieOpts $ reqList
output jsText output jsText
jsText `shouldContain` ("xsrfCookieName: 'MyXSRFcookie'") jsText `shouldContain` ("xsrfCookieName: 'MyXSRFcookie'")
it "should add withCredentials when needed" $ do it "should add withCredentials when needed" $ do
let jsText = genJS headerOpts $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS headerOpts $ reqList
output jsText output jsText
jsText `shouldContain` ("xsrfHeaderName: 'MyXSRFheader'") jsText `shouldContain` ("xsrfHeaderName: 'MyXSRFheader'")
where where
@ -121,18 +122,19 @@ axiosSpec = describe specLabel $ do
angularSpec :: TestNames -> Spec angularSpec :: TestNames -> Spec
angularSpec test = describe specLabel $ do angularSpec test = describe specLabel $ do
let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI)
it "should implement a service globally" $ do it "should implement a service globally" $ do
let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS reqList
output jsText output jsText
jsText `shouldContain` (".service('" <> testName <> "'") jsText `shouldContain` (".service('" <> testName <> "'")
it "should depend on $http service globally" $ do it "should depend on $http service globally" $ do
let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS reqList
output jsText output jsText
jsText `shouldContain` ("('" <> testName <> "', function($http) {") jsText `shouldContain` ("('" <> testName <> "', function($http) {")
it "should not depend on $http service in handlers" $ do it "should not depend on $http service in handlers" $ do
let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI) let jsText = genJS reqList
output jsText output jsText
jsText `shouldNotContain` "getsomething($http, " jsText `shouldNotContain` "getsomething($http, "
where where