mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-11-23 23:05:35 +03:00
Add Tests
This commit is contained in:
parent
9a5718ba06
commit
f33f613c14
82
tests/FindNoAnnotatedFunctionTest.elm
Normal file
82
tests/FindNoAnnotatedFunctionTest.elm
Normal file
@ -0,0 +1,82 @@
|
||||
port module FindNoAnnotatedFunctionTest exposing (all)
|
||||
|
||||
import Expect
|
||||
import Test exposing (describe, test, Test)
|
||||
import FindNoAnnotatedFunction exposing (rule)
|
||||
import Types exposing (Error)
|
||||
|
||||
|
||||
error : String -> Error
|
||||
error =
|
||||
Error "FindNoAnnotatedFunction"
|
||||
|
||||
|
||||
tests : List Test
|
||||
tests =
|
||||
[ test "should not report constants that are annotated" <|
|
||||
\() ->
|
||||
"""
|
||||
f : Int"
|
||||
f = 2
|
||||
"""
|
||||
|> rule
|
||||
|> Expect.equal []
|
||||
, test "should not report functions that are annotated" <|
|
||||
\() ->
|
||||
"""
|
||||
f : Int -> Int"
|
||||
f n = 2
|
||||
"""
|
||||
|> rule
|
||||
|> Expect.equal []
|
||||
, test "should report constants that are not annotated" <|
|
||||
\() ->
|
||||
"f = 2"
|
||||
|> rule
|
||||
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
||||
, test "should report functions that are not annotated" <|
|
||||
\() ->
|
||||
"f n = 2"
|
||||
|> rule
|
||||
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
||||
, test "should report functions that are not annotated" <|
|
||||
\() ->
|
||||
"f n = 2"
|
||||
|> rule
|
||||
|> Expect.equal [ error "`f` does not have a type declaration" ]
|
||||
, test "should report functions that are not annotated when there are annotations" <|
|
||||
\() ->
|
||||
"""
|
||||
f : Int -> Int
|
||||
g n = 3
|
||||
"""
|
||||
|> rule
|
||||
|> Expect.equal [ error "`g` does not have a type declaration" ]
|
||||
, test "should report functions that are not annotated when there are other annotated functions" <|
|
||||
\() ->
|
||||
"""
|
||||
f : Int -> Int
|
||||
f n = 2
|
||||
|
||||
g n = 3
|
||||
"""
|
||||
|> rule
|
||||
|> Expect.equal [ error "`g` does not have a type declaration" ]
|
||||
, test "should not functions declared in a `let` body" <|
|
||||
\() ->
|
||||
"""
|
||||
f : Int -> Int
|
||||
f n =
|
||||
let
|
||||
a = 2
|
||||
in
|
||||
a
|
||||
"""
|
||||
|> rule
|
||||
|> Expect.equal []
|
||||
]
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "FindNoAnnotatedFunction" tests
|
21
tests/Main.elm
Normal file
21
tests/Main.elm
Normal file
@ -0,0 +1,21 @@
|
||||
port module Tests exposing (..)
|
||||
|
||||
import Test exposing (describe, Test)
|
||||
import Test.Runner.Node exposing (run)
|
||||
import Json.Encode exposing (Value)
|
||||
import FindNoAnnotatedFunctionTest
|
||||
|
||||
|
||||
main : Test.Runner.Node.TestProgram
|
||||
main =
|
||||
run emit all
|
||||
|
||||
|
||||
port emit : ( String, Value ) -> Cmd msg
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "Visitors"
|
||||
[ FindNoAnnotatedFunctionTest.all
|
||||
]
|
22
tests/Visitors.log
Normal file
22
tests/Visitors.log
Normal file
@ -0,0 +1,22 @@
|
||||
module TestVisitor exposing (all)
|
||||
|
||||
import Expect
|
||||
import Test exposing (describe, test, Test)
|
||||
|
||||
|
||||
typeDeclarations : Test
|
||||
typeDeclarations =
|
||||
describe "type declarations"
|
||||
[ test "can parse aliases of unit" <|
|
||||
\() ->
|
||||
1
|
||||
|> Expect.equal 1
|
||||
-- emptyTupleAliasInput |> are [ TypeAliasDeclaration (TypeConstructor [ "A" ] []) (TypeTuple []) ]
|
||||
]
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "Visitor suite"
|
||||
[ typeDeclarations
|
||||
]
|
20
tests/elm-package.json
Normal file
20
tests/elm-package.json
Normal file
@ -0,0 +1,20 @@
|
||||
{
|
||||
"version": "1.0.0",
|
||||
"summary": "helpful summary of your project, less than 80 characters",
|
||||
"repository": "https://github.com/user/project.git",
|
||||
"license": "BSD3",
|
||||
"source-directories": [
|
||||
".",
|
||||
"..",
|
||||
"../rules"
|
||||
],
|
||||
"exposed-modules": [],
|
||||
"dependencies": {
|
||||
"elm-community/elm-test": "3.1.0 <= v < 4.0.0",
|
||||
"elm-lang/core": "5.0.0 <= v < 6.0.0",
|
||||
"elm-lang/html": "2.0.0 <= v < 3.0.0",
|
||||
"jfmengels/elm-ast": "1.0.1 <= v < 2.0.0",
|
||||
"rtfeldman/node-test-runner": "3.0.0 <= v < 4.0.0"
|
||||
},
|
||||
"elm-version": "0.18.0 <= v < 0.19.0"
|
||||
}
|
Loading…
Reference in New Issue
Block a user