A unit test for the target parser.
parent
d86284f09e
commit
809cca61b7
|
@ -1,9 +1,13 @@
|
||||||
|
{-# LANGUAGE CPP #-}
|
||||||
{-# LANGUAGE MultiWayIf #-}
|
{-# LANGUAGE MultiWayIf #-}
|
||||||
{-# LANGUAGE OverloadedStrings #-}
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
{-# LANGUAGE RecordWildCards #-}
|
{-# LANGUAGE RecordWildCards #-}
|
||||||
|
|
||||||
module Data.HTTPSEverywhere.Rules.Internal.Parser (
|
module Data.HTTPSEverywhere.Rules.Internal.Parser (
|
||||||
parseRuleSets
|
parseRuleSets,
|
||||||
|
#ifdef TEST
|
||||||
|
parseTarget
|
||||||
|
#endif
|
||||||
) where
|
) where
|
||||||
|
|
||||||
import Prelude hiding (head, last, tail, init)
|
import Prelude hiding (head, last, tail, init)
|
||||||
|
|
|
@ -0,0 +1,20 @@
|
||||||
|
{-# LANGUAGE OverloadedStrings #-}
|
||||||
|
|
||||||
|
module Data.HTTPSEverywhere.Rules.Internal.ParserSpec (
|
||||||
|
spec
|
||||||
|
) where
|
||||||
|
|
||||||
|
import Data.HTTPSEverywhere.Rules.Internal.Types (Target(..))
|
||||||
|
import Data.HTTPSEverywhere.Rules.Internal.Parser (parseTarget)
|
||||||
|
import Test.Hspec (Spec, describe, it, shouldBe)
|
||||||
|
|
||||||
|
spec :: Spec
|
||||||
|
spec = do
|
||||||
|
describe "parseTarget" $ do
|
||||||
|
let parseTarget' = \target domain -> ($ domain) . getTarget $ parseTarget target
|
||||||
|
it "*.facebook.com should match s-static.ak.facebook.com" $ do
|
||||||
|
parseTarget' "*.facebook.com" "s-static.ak.facebook.com" `shouldBe` True
|
||||||
|
it "google.* should match google.com.id" $ do
|
||||||
|
parseTarget' "google.*" "google.com.id" `shouldBe` True
|
||||||
|
it "*.google.* should not match google.com.id" $ do
|
||||||
|
parseTarget' "*.google.*" "google.com.id" `shouldBe` False
|
Loading…
Reference in New Issue