mirror of
https://github.com/ilyakooo0/purescript-spec-mocha.git
synced 2024-11-22 02:32:08 +03:00
update to work with spec v4
This commit is contained in:
parent
4f5ea639e5
commit
67e729fe24
@ -18,6 +18,6 @@
|
||||
"purescript-console": "^4.0.0",
|
||||
"purescript-foldable-traversable": "^4.0.0",
|
||||
"purescript-exceptions": "^4.0.0",
|
||||
"purescript-spec": "^3.0.0"
|
||||
"purescript-spec": "^4.0.0"
|
||||
}
|
||||
}
|
||||
|
@ -4,11 +4,14 @@ module Test.Spec.Mocha (
|
||||
) where
|
||||
|
||||
import Prelude
|
||||
import Effect.Aff (Aff, Error, runAff_)
|
||||
import Effect (Effect)
|
||||
|
||||
import Data.Either (either)
|
||||
import Data.Foldable (traverse_)
|
||||
import Test.Spec (Spec, Group(..), collect)
|
||||
import Data.Maybe (Maybe(..))
|
||||
import Effect (Effect)
|
||||
import Effect.Aff (Aff, Error, runAff_)
|
||||
import Test.Spec (SpecT, collect)
|
||||
import Test.Spec.Tree (Item(..), Tree(..))
|
||||
|
||||
foreign import data MOCHA :: Type
|
||||
|
||||
@ -31,19 +34,24 @@ foreign import describe
|
||||
-> Effect Unit
|
||||
|
||||
registerGroup
|
||||
:: Group (Aff Unit)
|
||||
:: ∀ m
|
||||
. Tree m (Item Aff Unit)
|
||||
-> Effect Unit
|
||||
registerGroup (It only name test) =
|
||||
itAsync only name cb
|
||||
registerGroup tree =
|
||||
case tree of
|
||||
Leaf name (Just (Item { isFocused, example })) ->
|
||||
itAsync isFocused name cb
|
||||
where
|
||||
cb onSuccess onError =
|
||||
runAff_ (either onError (const onSuccess)) test
|
||||
registerGroup (Pending name) = itPending name
|
||||
registerGroup (Describe only name groups) =
|
||||
describe only name (traverse_ registerGroup groups)
|
||||
runAff_ (either onError (const onSuccess)) (example (\a -> a unit))
|
||||
Leaf name Nothing ->
|
||||
itPending name
|
||||
Node a t ->
|
||||
traverse_ registerGroup t
|
||||
|
||||
runMocha
|
||||
:: forall e
|
||||
. Spec Unit
|
||||
:: ∀ a
|
||||
. SpecT Aff Unit Effect a
|
||||
-> Effect Unit
|
||||
runMocha spec = traverse_ registerGroup (collect spec)
|
||||
runMocha spec =
|
||||
traverse_ registerGroup =<< collect spec
|
||||
|
Loading…
Reference in New Issue
Block a user