Added some simple selector test cases

This commit is contained in:
Michael Snoyman 2012-03-28 08:18:19 +02:00
parent 0201415b05
commit 5e068b32b7
2 changed files with 12 additions and 1 deletions

View File

@ -4,8 +4,10 @@ import Test.Hspec.Monadic
import Test.Hspec.HUnit ()
import Yesod.Test.CssQuery
import Yesod.Test.TransversingCSS
parseQuery_ = either error id . parseQuery
findBySelector_ x = either error id . findBySelector x
main :: IO ()
main = hspecX $ do
@ -13,3 +15,12 @@ main = hspecX $ do
it "elements" $ parseQuery_ "strong" @?= [[DeepChildren [ByTagName "strong"]]]
it "child elements" $ parseQuery_ "strong > i" @?= [[DeepChildren [ByTagName "strong"], DirectChildren [ByTagName "i"]]]
it "comma" $ parseQuery_ "strong.bar, #foo" @?= [[DeepChildren [ByTagName "strong", ByClass "bar"]], [DeepChildren [ById "foo"]]]
describe "find by selector" $ do
it "XHTML" $
let html = "<html><head><title>foo</title></head><body><p>Hello World</p></body></html>"
query = "body > p"
in findBySelector_ html query @?= ["<p>Hello World</p>"]
it "HTML" $
let html = "<html><head><title>foo</title></head><body><br><p>Hello World</p></body></html>"
query = "body > p"
in findBySelector_ html query @?= ["<p>Hello World</p>"]

View File

@ -36,7 +36,7 @@ library
, text
exposed-modules: Yesod.Test
Yesod.Test.CssQuery
other-modules: Yesod.Test.TransversingCSS
Yesod.Test.TransversingCSS
ghc-options: -Wall
test-suite test