2020-01-28 21:41:14 +03:00
|
|
|
module Parser.StyleTest where
|
|
|
|
|
2020-09-23 15:34:24 +03:00
|
|
|
import Test.Tasty.Hspec
|
2020-01-28 21:41:14 +03:00
|
|
|
|
2020-09-23 15:34:24 +03:00
|
|
|
import Data.Either (isLeft)
|
|
|
|
import qualified Path.Posix as PPosix
|
2020-01-28 21:41:14 +03:00
|
|
|
|
2020-09-23 15:34:24 +03:00
|
|
|
import Parser.Common (runWaspParser)
|
|
|
|
import Parser.Style (style)
|
|
|
|
import qualified StrongPath as SP
|
2020-01-28 21:41:14 +03:00
|
|
|
import qualified Wasp.Style
|
|
|
|
|
|
|
|
|
|
|
|
spec_parseStyle :: Spec
|
|
|
|
spec_parseStyle = do
|
2020-02-05 00:39:38 +03:00
|
|
|
it "Parses external code file path correctly" $ do
|
2020-09-17 16:41:59 +03:00
|
|
|
runWaspParser style "\"@ext/some/file.css\""
|
2020-09-23 15:34:24 +03:00
|
|
|
`shouldBe` Right (Wasp.Style.ExtCodeCssFile (SP.fromPathRelFileP [PPosix.relfile|some/file.css|]))
|
2020-01-28 21:41:14 +03:00
|
|
|
|
|
|
|
it "Parses css closure correctly" $ do
|
|
|
|
runWaspParser style "{=css Some css code css=}"
|
|
|
|
`shouldBe` Right (Wasp.Style.CssCode "Some css code")
|
|
|
|
|
2020-02-05 00:39:38 +03:00
|
|
|
it "Throws error if path is not external code path." $ do
|
2020-09-17 16:41:59 +03:00
|
|
|
isLeft (runWaspParser style "\"some/file.css\"")
|
2020-01-28 21:41:14 +03:00
|
|
|
`shouldBe` True
|