Added some simple selector test cases
This commit is contained in:
parent
0201415b05
commit
5e068b32b7
@ -4,8 +4,10 @@ import Test.Hspec.Monadic
|
|||||||
import Test.Hspec.HUnit ()
|
import Test.Hspec.HUnit ()
|
||||||
|
|
||||||
import Yesod.Test.CssQuery
|
import Yesod.Test.CssQuery
|
||||||
|
import Yesod.Test.TransversingCSS
|
||||||
|
|
||||||
parseQuery_ = either error id . parseQuery
|
parseQuery_ = either error id . parseQuery
|
||||||
|
findBySelector_ x = either error id . findBySelector x
|
||||||
|
|
||||||
main :: IO ()
|
main :: IO ()
|
||||||
main = hspecX $ do
|
main = hspecX $ do
|
||||||
@ -13,3 +15,12 @@ main = hspecX $ do
|
|||||||
it "elements" $ parseQuery_ "strong" @?= [[DeepChildren [ByTagName "strong"]]]
|
it "elements" $ parseQuery_ "strong" @?= [[DeepChildren [ByTagName "strong"]]]
|
||||||
it "child elements" $ parseQuery_ "strong > i" @?= [[DeepChildren [ByTagName "strong"], DirectChildren [ByTagName "i"]]]
|
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"]]]
|
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>"]
|
||||||
|
|||||||
@ -36,7 +36,7 @@ library
|
|||||||
, text
|
, text
|
||||||
exposed-modules: Yesod.Test
|
exposed-modules: Yesod.Test
|
||||||
Yesod.Test.CssQuery
|
Yesod.Test.CssQuery
|
||||||
other-modules: Yesod.Test.TransversingCSS
|
Yesod.Test.TransversingCSS
|
||||||
ghc-options: -Wall
|
ghc-options: -Wall
|
||||||
|
|
||||||
test-suite test
|
test-suite test
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user