2016-03-12 09:03:57 +01:00
|
|
|
{-# LANGUAGE OverloadedStrings #-}
|
|
|
|
|
|
|
|
module JavascriptSpec where
|
|
|
|
|
|
|
|
import Data.List
|
|
|
|
import Data.String
|
|
|
|
import Data.String.Conversions
|
|
|
|
import Test.Hspec
|
|
|
|
import Test.Hspec.Wai
|
|
|
|
|
|
|
|
import Javascript
|
|
|
|
|
|
|
|
spec :: Spec
|
|
|
|
spec = do
|
|
|
|
describe "apiJS" $ do
|
|
|
|
it "is contained verbatim in Javascript.lhs" $ do
|
|
|
|
code <- readFile "Javascript.lhs"
|
2016-05-12 13:20:02 +02:00
|
|
|
cs apiJS1 `shouldSatisfy` (`isInfixOf` code)
|
|
|
|
cs apiJS3 `shouldSatisfy` (`isInfixOf` code)
|
|
|
|
cs apiJS4 `shouldSatisfy` (`isInfixOf` code)
|
|
|
|
cs apiJS6 `shouldSatisfy` (`isInfixOf` code)
|
2016-03-12 09:03:57 +01:00
|
|
|
|
|
|
|
describe "writeJSFiles" $ do
|
|
|
|
it "[not a test] write apiJS to static/api.js" $ do
|
|
|
|
writeJSFiles
|
|
|
|
|
|
|
|
describe "app" $ with (return app) $ do
|
|
|
|
context "/api.js" $ do
|
|
|
|
it "delivers apiJS" $ do
|
2016-05-12 13:20:02 +02:00
|
|
|
get "/api.js" `shouldRespondWith` (fromString (cs apiJS1))
|
2016-03-12 09:03:57 +01:00
|
|
|
|
|
|
|
context "/" $ do
|
|
|
|
it "delivers something" $ do
|
|
|
|
get "" `shouldRespondWith` 200
|
|
|
|
get "/" `shouldRespondWith` 200
|