wasp/waspc/test/Parser/ExternalCodeTest.hs
2020-09-23 15:44:32 +02:00

22 lines
839 B
Haskell

module Parser.ExternalCodeTest where
import Test.Tasty.Hspec
import Data.Either (isLeft)
import qualified Path.Posix as PPosix
import Parser.Common (runWaspParser)
import Parser.ExternalCode (extCodeFilePathString)
import qualified StrongPath as SP
spec_ParserExternalCode :: Spec
spec_ParserExternalCode = do
describe "Parsing external code file path string" $ do
it "Correctly parses external code path in double quotes" $ do
runWaspParser extCodeFilePathString "\"@ext/foo/bar.txt\""
`shouldBe` Right (SP.fromPathRelFileP [PPosix.relfile|foo/bar.txt|])
it "When path does not start with @ext/, returns Left" $ do
isLeft (runWaspParser extCodeFilePathString "\"@ext2/foo/bar.txt\"") `shouldBe` True