mirror of
https://github.com/dillonkearns/elm-pages.git
synced 2024-10-26 10:27:36 +03:00
Move final test cases to glob end-to-end test suite.
This commit is contained in:
parent
bb81c49d0e
commit
a0c378a1df
@ -246,6 +246,19 @@ all =
|
||||
[ ( [ "a", "b", "c" ], "d" )
|
||||
]
|
||||
}
|
||||
, globTestCase
|
||||
{ name = "zeroOrMore"
|
||||
, glob =
|
||||
Glob.succeed identity
|
||||
|> Glob.match (Glob.literal "glob-test-cases/zero-or-more/test/a")
|
||||
|> Glob.capture (Glob.zeroOrMore [ "a", "b" ])
|
||||
|> Glob.match (Glob.literal "/x.js")
|
||||
, expected =
|
||||
[ Nothing
|
||||
, Just "b"
|
||||
, Just "ba"
|
||||
]
|
||||
}
|
||||
]
|
||||
|> DataSource.combine
|
||||
|> DataSource.map (describe "glob tests")
|
||||
|
@ -1,91 +0,0 @@
|
||||
module GlobTests exposing (all)
|
||||
|
||||
import DataSource.Glob as Glob
|
||||
import DataSource.Internal.Glob
|
||||
import Expect
|
||||
import Test exposing (Test, describe, test)
|
||||
|
||||
|
||||
all : Test
|
||||
all =
|
||||
describe "glob"
|
||||
[ test "optional group - no match" <|
|
||||
\() ->
|
||||
zeroOrMoreGlob
|
||||
|> expect "test/a/x.js"
|
||||
-- test/a/x.js
|
||||
-- https://github.com/micromatch/micromatch/blob/fe4858b0c63b174fd3ae22674db39119b8fa4392/test/api.capture.js#L42
|
||||
{ expectedMatch = Nothing
|
||||
, expectedPattern = "test/a*(a|b)/x.js"
|
||||
}
|
||||
, test "optional group - single match" <|
|
||||
\() ->
|
||||
zeroOrMoreGlob
|
||||
|> expect "test/ab/x.js"
|
||||
-- test/ab/x.js
|
||||
-- https://github.com/micromatch/micromatch/blob/fe4858b0c63b174fd3ae22674db39119b8fa4392/test/api.capture.js#L44
|
||||
{ expectedMatch = Just "b"
|
||||
, expectedPattern = "test/a*(a|b)/x.js"
|
||||
}
|
||||
, test "optional group - multiple matches" <|
|
||||
\() ->
|
||||
zeroOrMoreGlob
|
||||
|> expect "test/aba/x.js"
|
||||
-- test/aba/x.js
|
||||
-- https://github.com/micromatch/micromatch/blob/fe4858b0c63b174fd3ae22674db39119b8fa4392/test/api.capture.js#L45
|
||||
{ expectedMatch = Just "ba"
|
||||
, expectedPattern = "test/a*(a|b)/x.js"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
type HasIndex
|
||||
= WithIndex
|
||||
| NoIndex
|
||||
|
||||
|
||||
zeroOrMoreGlob : Glob.Glob (Maybe String)
|
||||
zeroOrMoreGlob =
|
||||
Glob.succeed identity
|
||||
|> Glob.match (Glob.literal "test/a")
|
||||
|> Glob.capture (Glob.zeroOrMore [ "a", "b" ])
|
||||
|> Glob.match (Glob.literal "/x.js")
|
||||
|
||||
|
||||
type DataExtension
|
||||
= Yml
|
||||
| Json
|
||||
|
||||
|
||||
expect :
|
||||
String
|
||||
->
|
||||
{ expectedMatch : match
|
||||
, expectedPattern : String
|
||||
}
|
||||
-> Glob.Glob match
|
||||
-> Expect.Expectation
|
||||
expect filePath { expectedMatch, expectedPattern } glob =
|
||||
glob
|
||||
|> DataSource.Internal.Glob.run filePath
|
||||
|> Expect.equal
|
||||
{ pattern = expectedPattern
|
||||
, match = expectedMatch
|
||||
}
|
||||
|
||||
|
||||
expectAll :
|
||||
List ( String, match )
|
||||
-> Glob.Glob match
|
||||
-> Expect.Expectation
|
||||
expectAll expectedPairs glob =
|
||||
expectedPairs
|
||||
|> List.map
|
||||
(\( filePath, _ ) ->
|
||||
( filePath
|
||||
, glob
|
||||
|> DataSource.Internal.Glob.run filePath
|
||||
|> .match
|
||||
)
|
||||
)
|
||||
|> Expect.equalLists expectedPairs
|
Loading…
Reference in New Issue
Block a user