Skip to content

Commit 67e729f

Browse files
JCSanPedroowickstrom
authored andcommitted
update to work with spec v4
1 parent 4f5ea63 commit 67e729f

File tree

2 files changed

+24
-16
lines changed

2 files changed

+24
-16
lines changed

bower.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@
1818
"purescript-console": "^4.0.0",
1919
"purescript-foldable-traversable": "^4.0.0",
2020
"purescript-exceptions": "^4.0.0",
21-
"purescript-spec": "^3.0.0"
21+
"purescript-spec": "^4.0.0"
2222
}
2323
}

src/Test/Spec/Mocha.purs

Lines changed: 23 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,14 @@ module Test.Spec.Mocha (
44
) where
55

66
import Prelude
7-
import Effect.Aff (Aff, Error, runAff_)
8-
import Effect (Effect)
7+
98
import Data.Either (either)
109
import Data.Foldable (traverse_)
11-
import Test.Spec (Spec, Group(..), collect)
10+
import Data.Maybe (Maybe(..))
11+
import Effect (Effect)
12+
import Effect.Aff (Aff, Error, runAff_)
13+
import Test.Spec (SpecT, collect)
14+
import Test.Spec.Tree (Item(..), Tree(..))
1215

1316
foreign import data MOCHA :: Type
1417

@@ -31,19 +34,24 @@ foreign import describe
3134
-> Effect Unit
3235

3336
registerGroup
34-
:: Group (Aff Unit)
37+
:: m
38+
. Tree m (Item Aff Unit)
3539
-> Effect Unit
36-
registerGroup (It only name test) =
37-
itAsync only name cb
38-
where
39-
cb onSuccess onError =
40-
runAff_ (either onError (const onSuccess)) test
41-
registerGroup (Pending name) = itPending name
42-
registerGroup (Describe only name groups) =
43-
describe only name (traverse_ registerGroup groups)
40+
registerGroup tree =
41+
case tree of
42+
Leaf name (Just (Item { isFocused, example })) ->
43+
itAsync isFocused name cb
44+
where
45+
cb onSuccess onError =
46+
runAff_ (either onError (const onSuccess)) (example (\a -> a unit))
47+
Leaf name Nothing ->
48+
itPending name
49+
Node a t ->
50+
traverse_ registerGroup t
4451

4552
runMocha
46-
:: forall e
47-
. Spec Unit
53+
:: a
54+
. SpecT Aff Unit Effect a
4855
-> Effect Unit
49-
runMocha spec = traverse_ registerGroup (collect spec)
56+
runMocha spec =
57+
traverse_ registerGroup =<< collect spec

0 commit comments

Comments
 (0)