wasp/waspc/test/Parser/PageTest.hs

34 lines
1.2 KiB
Haskell
Raw Normal View History

module Parser.PageTest where
import Test.Tasty.Hspec
2019-05-09 23:05:59 +03:00
import Data.Either (isLeft)
2019-05-09 23:05:59 +03:00
import Parser.Common (runWaspParser)
import Parser.Page (page)
import qualified Wasp
spec_parsePage :: Spec
spec_parsePage =
describe "Parsing page wasp" $ do
2019-05-09 23:05:59 +03:00
let parsePage input = runWaspParser page input
it "When given valid page wasp declaration, returns correct Wasp.Page" $ do
let testPageName = "Landing"
let testPageRoute = "/someRoute"
let testPageContent = "<span/>"
parsePage (
"page " ++ testPageName ++ " { " ++
"route: \"" ++ testPageRoute ++ "\"," ++
"content: {=jsx " ++ testPageContent ++ " jsx=}" ++
"}")
2019-05-09 23:05:59 +03:00
`shouldBe` Right (Wasp.Page
{ Wasp.pageName = testPageName
, Wasp.pageRoute = testPageRoute
, Wasp.pageContent = testPageContent
, Wasp.pageStyle = Nothing
})
it "When given page wasp declaration without 'page', should return Left" $ do
isLeft (parsePage "Landing { route: someRoute }") `shouldBe` True