diff --git a/bower.json b/bower.json index f2fdbe8..ea128af 100644 --- a/bower.json +++ b/bower.json @@ -19,6 +19,6 @@ "purescript-console": "^2.0.0", "purescript-foldable-traversable": "^2.0.0", "purescript-exceptions": "~2.0.0", - "purescript-spec": "^0.10.0" + "purescript-spec": "^0.11.0" } } diff --git a/karma.conf.js b/karma.conf.js index cfe3571..2e6f8c7 100644 --- a/karma.conf.js +++ b/karma.conf.js @@ -33,7 +33,7 @@ module.exports = function(config) { // test results reporter to use // possible values: 'dots', 'progress' // available reporters: https://npmjs.org/browse/keyword/karma-reporter - reporters: ['progress', 'bdd'], + reporters: ['progress'], // web server port diff --git a/src/Test/Spec/Mocha.js b/src/Test/Spec/Mocha.js index fe40c36..6219964 100644 --- a/src/Test/Spec/Mocha.js +++ b/src/Test/Spec/Mocha.js @@ -2,21 +2,24 @@ // module Test.Spec.Mocha -if (!describe || !it) { +if (typeof describe !== 'function' || typeof it !== 'function') { throw new Error('Mocha globals seem to be unavailable!'); } -exports.itAsync = function (name) { +exports.itAsync = function (only) { "use strict"; - return function (aff) { - return function () { - it(name, function (done) { - aff(function () { - done(); - }, function (err) { - done(err); - }) - }); + return function (name) { + return function (aff) { + return function () { + var f = only ? it.only : it; + f(name, function (done) { + aff(function () { + done(); + }, function (err) { + done(err); + }); + }); + }; }; }; }; @@ -28,13 +31,16 @@ exports.itPending = function (name) { }; }; -exports.describe = function (name) { +exports.describe = function (only) { "use strict"; - return function (nested) { - return function () { - describe(name, function () { - nested(); - }); + return function (name) { + return function (nested) { + return function () { + var f = only ? describe : describe.only; + f(name, function () { + nested(); + }); + }; }; }; }; diff --git a/src/Test/Spec/Mocha.purs b/src/Test/Spec/Mocha.purs index 6a39b0e..bfbbca6 100644 --- a/src/Test/Spec/Mocha.purs +++ b/src/Test/Spec/Mocha.purs @@ -14,23 +14,27 @@ import Test.Spec (Spec, Group(..), collect) foreign import data MOCHA :: ! -foreign import itAsync :: forall e. String - -> Aff e Unit - -> Eff (mocha :: MOCHA | e) Unit +foreign import itAsync :: forall e. + Boolean + -> String + -> Aff e Unit + -> Eff (mocha :: MOCHA | e) Unit foreign import itPending :: forall e. String -> Eff (mocha :: MOCHA | e) Unit -foreign import describe :: forall e. String +foreign import describe :: forall e. + Boolean + -> String -> Eff (mocha :: MOCHA | e) Unit -> Eff (mocha :: MOCHA | e) Unit registerGroup :: forall e. (Group (Aff e Unit)) -> Eff (mocha :: MOCHA | e) Unit -registerGroup (It name test) = itAsync name test +registerGroup (It only name test) = itAsync only name test registerGroup (Pending name) = itPending name -registerGroup (Describe name groups) = - describe name (traverse_ registerGroup groups) +registerGroup (Describe only name groups) = + describe only name (traverse_ registerGroup groups) runMocha :: forall e. Spec e Unit -> Eff (mocha :: MOCHA | e) Unit diff --git a/test/Main.purs b/test/Main.purs index d4b95c7..06c1924 100644 --- a/test/Main.purs +++ b/test/Main.purs @@ -1,13 +1,13 @@ module Test.Main where import Prelude - import Control.Monad.Aff (later') - -import Test.Spec (describe, it, pending) +import Control.Monad.Eff (Eff) +import Test.Spec (SpecEffects, describe, it, pending) import Test.Spec.Assertions (shouldEqual) -import Test.Spec.Mocha (runMocha) +import Test.Spec.Mocha (MOCHA, runMocha) +main :: Eff (SpecEffects (mocha :: MOCHA)) Unit main = runMocha do describe "test" $ describe "nested" do