~ubuntu-branches/ubuntu/utopic/haskell-wai-extra/utopic-proposed

« back to all changes in this revision

Viewing changes to test/Network/Wai/TestSpec.hs

  • Committer: Package Import Robot
  • Author(s): Clint Adams
  • Date: 2014-06-06 11:40:45 UTC
  • mfrom: (15.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20140606114045-cc7h7xuui844a1l0
Tags: 3.0.0-1
New upstream version.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
{-# LANGUAGE OverloadedStrings #-}
 
2
module Network.Wai.TestSpec (main, spec) where
 
3
 
 
4
import           Test.Hspec
 
5
 
 
6
import           Network.Wai
 
7
import           Network.Wai.Test
 
8
 
 
9
main :: IO ()
 
10
main = hspec spec
 
11
 
 
12
spec :: Spec
 
13
spec = do
 
14
  describe "setPath" $ do
 
15
 
 
16
    let req = setPath defaultRequest "/foo/bar/baz?foo=23&bar=42&baz"
 
17
 
 
18
    it "sets pathInfo" $ do
 
19
      pathInfo req `shouldBe` ["foo", "bar", "baz"]
 
20
 
 
21
    it "utf8 path" $
 
22
      pathInfo (setPath defaultRequest "/foo/%D7%A9%D7%9C%D7%95%D7%9D/bar") `shouldBe`
 
23
        ["foo", "שלום", "bar"]
 
24
 
 
25
    it "sets rawPathInfo" $ do
 
26
      rawPathInfo req `shouldBe` "/foo/bar/baz"
 
27
 
 
28
    it "sets queryString" $ do
 
29
      queryString req `shouldBe` [("foo", Just "23"), ("bar", Just "42"), ("baz", Nothing)]
 
30
 
 
31
    it "sets rawQueryString" $ do
 
32
      rawQueryString req `shouldBe` "?foo=23&bar=42&baz"
 
33
 
 
34
    context "when path has no query string" $ do
 
35
      it "sets rawQueryString to empty string" $ do
 
36
        rawQueryString (setPath defaultRequest "/foo/bar/baz") `shouldBe` ""