git.iko.soy/typeable/servant
on master help sign in
Fix broken servant-js tests.
0c0c382Maksymilian Owsianny
servant-js/src/Servant/JS.hs+1
@@ -110,6 +110,7 @@ module Servant.JS
110 , -- * Misc.
110 , -- * Misc.
111 listFromAPI
111 listFromAPI
112 , javascript
112 , javascript
113+ , LangJS
113 , GenerateList(..)
114 , GenerateList(..)
114 ) where
115 ) where
115
116
servant-js/test/Servant/JSSpec.hs+8−6
@@ -98,16 +98,17 @@ a `shouldNotContain` b = shouldNotSatisfy a (T.isInfixOf b)
98
98
99axiosSpec :: Spec
99axiosSpec :: Spec
100axiosSpec = describe specLabel $ do
100axiosSpec = describe specLabel $ do
101+ let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI)
101 it "should add withCredentials when needed" $ do
102 it "should add withCredentials when needed" $ do
102− let jsText = genJS withCredOpts $ listFromAPI (Proxy :: Proxy TestAPI)
103+ let jsText = genJS withCredOpts $ reqList
103 output jsText
104 output jsText
104 jsText `shouldContain` "withCredentials: true"
105 jsText `shouldContain` "withCredentials: true"
105 it "should add xsrfCookieName when needed" $ do
106 it "should add xsrfCookieName when needed" $ do
106− let jsText = genJS cookieOpts $ listFromAPI (Proxy :: Proxy TestAPI)
107+ let jsText = genJS cookieOpts $ reqList
107 output jsText
108 output jsText
108 jsText `shouldContain` ("xsrfCookieName: 'MyXSRFcookie'")
109 jsText `shouldContain` ("xsrfCookieName: 'MyXSRFcookie'")
109 it "should add withCredentials when needed" $ do
110 it "should add withCredentials when needed" $ do
110− let jsText = genJS headerOpts $ listFromAPI (Proxy :: Proxy TestAPI)
111+ let jsText = genJS headerOpts $ reqList
111 output jsText
112 output jsText
112 jsText `shouldContain` ("xsrfHeaderName: 'MyXSRFheader'")
113 jsText `shouldContain` ("xsrfHeaderName: 'MyXSRFheader'")
113 where
114 where
@@ -121,18 +122,19 @@ axiosSpec = describe specLabel $ do
121
122
122angularSpec :: TestNames -> Spec
123angularSpec :: TestNames -> Spec
123angularSpec test = describe specLabel $ do
124angularSpec test = describe specLabel $ do
125+ let reqList = listFromAPI (Proxy :: Proxy LangJS) (Proxy :: Proxy TestAPI)
124 it "should implement a service globally" $ do
126 it "should implement a service globally" $ do
125− let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI)
127+ let jsText = genJS reqList
126 output jsText
128 output jsText
127 jsText `shouldContain` (".service('" <> testName <> "'")
129 jsText `shouldContain` (".service('" <> testName <> "'")
128
130
129 it "should depend on $http service globally" $ do
131 it "should depend on $http service globally" $ do
130− let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI)
132+ let jsText = genJS reqList
131 output jsText
133 output jsText
132 jsText `shouldContain` ("('" <> testName <> "', function($http) {")
134 jsText `shouldContain` ("('" <> testName <> "', function($http) {")
133
135
134 it "should not depend on $http service in handlers" $ do
136 it "should not depend on $http service in handlers" $ do
135− let jsText = genJS $ listFromAPI (Proxy :: Proxy TestAPI)
137+ let jsText = genJS reqList
136 output jsText
138 output jsText
137 jsText `shouldNotContain` "getsomething($http, "
139 jsText `shouldNotContain` "getsomething($http, "
138 where
140 where