Skip to content

Commit

Permalink
move test
Browse files Browse the repository at this point in the history
  • Loading branch information
zachary822 committed Dec 17, 2023
1 parent 705fc52 commit 8b8270b
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions test/Web/ScottySpec.hs
Original file line number Diff line number Diff line change
Expand Up @@ -174,6 +174,16 @@ spec = do
it "Responds with a 302 Redirect" $ do
get "/a" `shouldRespondWith` 302 { matchHeaders = ["Location" <:> "/b"] }

describe "middleware" $ do
context "rewrites the query string" $ do
withApp (do
Scotty.middleware $ \app req sendResponse ->
app req{queryString = [("query", Just "haskell")]} sendResponse
Scotty.matchAny "/search" $ queryParam "query" >>= text
) $ do
it "returns query parameter with given name" $ do
get "/search" `shouldRespondWith` "haskell"

describe "captureParam" $ do
withApp (
do
Expand Down Expand Up @@ -227,15 +237,6 @@ spec = do
) $ do
it "catches a ScottyException" $ do
get "/search?query=potato" `shouldRespondWith` 200 { matchBody = "z"}
context "returns query parameter with given name after middleware rewrite" $ do
withApp (do
Scotty.middleware $ \app req sendResponse ->
app req{queryString = [("query", Just "haskell")]} sendResponse
Scotty.matchAny "/search" $ queryParam "query" >>= text
) $ do
it "returns query parameter with given name" $ do
get "/search" `shouldRespondWith` "haskell"


describe "formParam" $ do
let
Expand Down

0 comments on commit 8b8270b

Please sign in to comment.