mirror of
https://github.com/wasp-lang/wasp.git
synced 2024-12-25 10:03:07 +03:00
Formatted tests with ormolu.
This commit is contained in:
parent
29fd18dbcc
commit
0b02e45354
@ -1,7 +1,7 @@
|
||||
module Parser.ActionTest where
|
||||
|
||||
import Data.Either (isLeft)
|
||||
import Data.Char (toLower)
|
||||
import Data.Either (isLeft)
|
||||
import Parser.Action (action)
|
||||
import Parser.Common (runWaspParser)
|
||||
import qualified StrongPath as SP
|
||||
@ -18,7 +18,8 @@ spec_parseAction :: Spec
|
||||
spec_parseAction =
|
||||
describe "Parsing action declaration" $ do
|
||||
let parseAction = runWaspParser action
|
||||
let testWhenAuth auth = it ("When given a valid action declaration, returns correct AST(action.auth = " ++ show auth ++ ")") $
|
||||
let testWhenAuth auth =
|
||||
it ("When given a valid action declaration, returns correct AST(action.auth = " ++ show auth ++ ")") $
|
||||
parseAction (genActionCode auth) `shouldBe` Right (genActionAST auth)
|
||||
testWhenAuth (Just True)
|
||||
testWhenAuth (Just False)
|
||||
@ -27,7 +28,8 @@ spec_parseAction =
|
||||
isLeft (parseAction "action myAction { }") `shouldBe` True
|
||||
where
|
||||
genActionAST :: Maybe Bool -> Wasp.Action.Action
|
||||
genActionAST aApplyAuth = Wasp.Action.Action
|
||||
genActionAST aApplyAuth =
|
||||
Wasp.Action.Action
|
||||
{ Wasp.Action._name = testActionName,
|
||||
Wasp.Action._jsFunction =
|
||||
Wasp.JsImport.JsImport
|
||||
@ -39,8 +41,8 @@ spec_parseAction =
|
||||
Wasp.Action._auth = aApplyAuth
|
||||
}
|
||||
genActionCode :: Maybe Bool -> String
|
||||
genActionCode aApplyAuth = (
|
||||
"action " ++ testActionName ++ " {\n"
|
||||
genActionCode aApplyAuth =
|
||||
( "action " ++ testActionName ++ " {\n"
|
||||
++ " fn: import { "
|
||||
++ testActionJsFunctionName
|
||||
++ " } from \"@ext/some/path\""
|
||||
|
@ -1,5 +1,6 @@
|
||||
module Parser.QueryTest where
|
||||
|
||||
import Data.Char (toLower)
|
||||
import Data.Either (isLeft)
|
||||
import Parser.Common (runWaspParser)
|
||||
import Parser.Query (query)
|
||||
@ -7,13 +8,13 @@ import qualified StrongPath as SP
|
||||
import Test.Tasty.Hspec
|
||||
import qualified Wasp.JsImport
|
||||
import qualified Wasp.Query
|
||||
import Data.Char (toLower)
|
||||
|
||||
spec_parseQuery :: Spec
|
||||
spec_parseQuery =
|
||||
describe "Parsing query declaration" $ do
|
||||
let parseQuery = runWaspParser query
|
||||
let testWhenAuth auth = it ("When given a valid query declaration, returns correct AST(query.auth = " ++ show auth ++ ")") $
|
||||
let testWhenAuth auth =
|
||||
it ("When given a valid query declaration, returns correct AST(query.auth = " ++ show auth ++ ")") $
|
||||
parseQuery (genQueryCode auth) `shouldBe` Right (genQueryAST auth)
|
||||
testWhenAuth (Just True)
|
||||
testWhenAuth (Just False)
|
||||
@ -22,8 +23,8 @@ spec_parseQuery =
|
||||
isLeft (parseQuery "query myQuery { }") `shouldBe` True
|
||||
where
|
||||
genQueryCode :: Maybe Bool -> String
|
||||
genQueryCode qApplyAuth = (
|
||||
"query " ++ testQueryName ++ " {\n"
|
||||
genQueryCode qApplyAuth =
|
||||
( "query " ++ testQueryName ++ " {\n"
|
||||
++ " fn: import { "
|
||||
++ testQueryJsFunctionName
|
||||
++ " } from \"@ext/some/path\",\n"
|
||||
@ -32,7 +33,8 @@ spec_parseQuery =
|
||||
++ "}"
|
||||
)
|
||||
genQueryAST :: Maybe Bool -> Wasp.Query.Query
|
||||
genQueryAST qApplyAuth = Wasp.Query.Query
|
||||
genQueryAST qApplyAuth =
|
||||
Wasp.Query.Query
|
||||
{ Wasp.Query._name = testQueryName,
|
||||
Wasp.Query._jsFunction =
|
||||
Wasp.JsImport.JsImport
|
||||
@ -50,4 +52,3 @@ spec_parseQuery =
|
||||
testQueryName = "myQuery"
|
||||
testQueryJsFunctionName = "myJsQuery"
|
||||
testQueryJsFunctionFrom = [SP.relfileP|some/path|]
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user