mirror of
https://github.com/jfmengels/elm-review.git
synced 2024-12-27 03:33:00 +03:00
Use new test module for NoImportingEverything
This commit is contained in:
parent
7c1fe28ede
commit
98d88e691e
@ -1,21 +1,13 @@
|
|||||||
module NoImportingEverythingTest exposing (all)
|
module NoImportingEverythingTest exposing (all)
|
||||||
|
|
||||||
import Elm.Syntax.Range exposing (Location, Range)
|
|
||||||
import Lint.Rule as Rule exposing (Error, Rule)
|
|
||||||
import Lint.Rule.NoImportingEverything exposing (Configuration, rule)
|
import Lint.Rule.NoImportingEverything exposing (Configuration, rule)
|
||||||
import Lint.Test exposing (LintResult)
|
import Lint.Test2 exposing (LintResult)
|
||||||
import Lint.Test2
|
|
||||||
import Test exposing (Test, describe, test)
|
import Test exposing (Test, describe, test)
|
||||||
|
|
||||||
|
|
||||||
testRule : Configuration -> String -> LintResult
|
testRule : Configuration -> String -> LintResult
|
||||||
testRule options =
|
testRule options =
|
||||||
Lint.Test.run (rule options)
|
Lint.Test2.run (rule options)
|
||||||
|
|
||||||
|
|
||||||
error : String -> Error
|
|
||||||
error message =
|
|
||||||
Lint.Test.errorWithoutRange message
|
|
||||||
|
|
||||||
|
|
||||||
tests : List Test
|
tests : List Test
|
||||||
@ -24,164 +16,93 @@ tests =
|
|||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (..)
|
||||||
import Html
|
import Html
|
||||||
import Http
|
import Http"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [] }
|
|> testRule { exceptions = [] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange []
|
|> Lint.Test2.expectNoErrors
|
||||||
, test "should not report imports that expose functions by name" <|
|
, test "should not report imports that expose functions by name" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (..)
|
||||||
import Html exposing (a)
|
import Html exposing (a)
|
||||||
import Http exposing (a, b)
|
import Http exposing (a, b)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [] }
|
|> testRule { exceptions = [] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange []
|
|> Lint.Test2.expectNoErrors
|
||||||
, test "should report imports that expose everything" <|
|
, test "should report imports that expose everything" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (..)
|
||||||
import Html exposing (..)
|
import Html exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [] }
|
|> testRule { exceptions = [] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange
|
|> Lint.Test2.expectErrors
|
||||||
[ error "Do not expose everything from Html" ]
|
[ Lint.Test2.error
|
||||||
|
{ message = "Do not expose everything from Html"
|
||||||
|
, under = ".."
|
||||||
|
}
|
||||||
|
|> Lint.Test2.atExactly { start = { row = 2, column = 23 }, end = { row = 2, column = 25 } }
|
||||||
|
]
|
||||||
, test "should report imports from sub-modules" <|
|
, test "should report imports from sub-modules" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html.App exposing (..)
|
import Html.App exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [] }
|
|> testRule { exceptions = [] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.App" ]
|
|> Lint.Test2.expectErrors
|
||||||
|
[ Lint.Test2.error
|
||||||
|
{ message = "Do not expose everything from Html.App"
|
||||||
|
, under = ".."
|
||||||
|
}
|
||||||
|
]
|
||||||
, test "should report imports from sub-modules (multiple dots)" <|
|
, test "should report imports from sub-modules (multiple dots)" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html.Foo.Bar exposing (..)
|
import Html.Foo.Bar exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [] }
|
|> testRule { exceptions = [] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.Foo.Bar" ]
|
|> Lint.Test2.expectErrors
|
||||||
|
[ Lint.Test2.error
|
||||||
|
{ message = "Do not expose everything from Html.Foo.Bar"
|
||||||
|
, under = ".."
|
||||||
|
}
|
||||||
|
]
|
||||||
, test "should not report imports that expose everything that are in the exception list" <|
|
, test "should not report imports that expose everything that are in the exception list" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html exposing (..)
|
import Html exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [ "Html" ] }
|
|> testRule { exceptions = [ "Html" ] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange []
|
|> Lint.Test2.expectNoErrors
|
||||||
, test "should not report imports from sub-modules that are in the exception list" <|
|
, test "should not report imports from sub-modules that are in the exception list" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html.App exposing (..)
|
import Html.App exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [ "Html.App" ] }
|
|> testRule { exceptions = [ "Html.App" ] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange []
|
|> Lint.Test2.expectNoErrors
|
||||||
, test "should not report imports from sub-modules (multiple dots)" <|
|
, test "should not report imports from sub-modules (multiple dots)" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html.Foo.Bar exposing (..)
|
import Html.Foo.Bar exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [ "Html.Foo.Bar" ] }
|
|> testRule { exceptions = [ "Html.Foo.Bar" ] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange []
|
|> Lint.Test2.expectNoErrors
|
||||||
, test "should report imports whose parent is ignored" <|
|
, test "should report imports whose parent is ignored" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html.Foo.Bar exposing (..)
|
import Html.Foo.Bar exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [ "Html" ] }
|
|> testRule { exceptions = [ "Html" ] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.Foo.Bar" ]
|
|> Lint.Test2.expectErrors
|
||||||
|
[ Lint.Test2.error
|
||||||
|
{ message = "Do not expose everything from Html.Foo.Bar"
|
||||||
|
, under = ".."
|
||||||
|
}
|
||||||
|
]
|
||||||
, test "should report imports whose sub-module is ignored" <|
|
, test "should report imports whose sub-module is ignored" <|
|
||||||
\() ->
|
\() ->
|
||||||
"""module A exposing (..)
|
"""module A exposing (a)
|
||||||
import Html exposing (..)
|
import Html exposing (..)"""
|
||||||
"""
|
|
||||||
|> testRule { exceptions = [ "Html.App" ] }
|
|> testRule { exceptions = [ "Html.App" ] }
|
||||||
|> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html" ]
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
testRule2 : Configuration -> String -> Lint.Test2.LintResult
|
|
||||||
testRule2 options =
|
|
||||||
Lint.Test2.run (rule options)
|
|
||||||
|
|
||||||
|
|
||||||
tests2 : List Test
|
|
||||||
tests2 =
|
|
||||||
[ test "A-should not report imports that do not expose anything" <|
|
|
||||||
\() ->
|
|
||||||
"""module A exposing (..)
|
|
||||||
import Html
|
|
||||||
import Http
|
|
||||||
"""
|
|
||||||
|> testRule2 { exceptions = [] }
|
|
||||||
|> Lint.Test2.expectNoErrors
|
|
||||||
, test "A-should not report imports that expose functions by name" <|
|
|
||||||
\() ->
|
|
||||||
"""module A exposing (..)
|
|
||||||
import Html exposing (a)
|
|
||||||
import Http exposing (a, b)"""
|
|
||||||
|> testRule2 { exceptions = [] }
|
|
||||||
|> Lint.Test2.expectNoErrors
|
|
||||||
, test "A-should report imports that expose everything" <|
|
|
||||||
\() ->
|
|
||||||
"""module A exposing (..)
|
|
||||||
import Html exposing
|
|
||||||
(..)"""
|
|
||||||
|> testRule2 { exceptions = [] }
|
|
||||||
|> Lint.Test2.expectErrors
|
|> Lint.Test2.expectErrors
|
||||||
[ Lint.Test2.error "Do not expose everything from Html"
|
[ Lint.Test2.error
|
||||||
|> Lint.Test2.under "(..)"
|
{ message = "Do not expose everything from Html"
|
||||||
|
, under = ".."
|
||||||
|
}
|
||||||
]
|
]
|
||||||
|
|
||||||
-- [ error "Do not expose everything from Html" ]
|
|
||||||
-- , test "A-should report imports from sub-modules" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html.App exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.App" ]
|
|
||||||
-- , test "A-should report imports from sub-modules (multiple dots)" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html.Foo.Bar exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.Foo.Bar" ]
|
|
||||||
-- , test "A-should not report imports that expose everything that are in the exception list" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [ "Html" ] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange []
|
|
||||||
-- , test "A-should not report imports from sub-modules that are in the exception list" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html.App exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [ "Html.App" ] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange []
|
|
||||||
-- , test "A-should not report imports from sub-modules (multiple dots)" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html.Foo.Bar exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [ "Html.Foo.Bar" ] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange []
|
|
||||||
-- , test "A-should report imports whose parent is ignored" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html.Foo.Bar exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [ "Html" ] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html.Foo.Bar" ]
|
|
||||||
-- , test "A-should report imports whose sub-module is ignored" <|
|
|
||||||
-- \() ->
|
|
||||||
-- """module A exposing (..)
|
|
||||||
-- import Html exposing (..)
|
|
||||||
-- """
|
|
||||||
-- |> testRule { exceptions = [ "Html.App" ] }
|
|
||||||
-- |> Lint.Test.expectErrorsWithoutRange [ error "Do not expose everything from Html" ]
|
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
all : Test
|
all : Test
|
||||||
all =
|
all =
|
||||||
describe "NoImportingEverything" (tests ++ tests2)
|
describe "NoImportingEverything" tests
|
||||||
|
Loading…
Reference in New Issue
Block a user