Adapt to purescript-spec-0.11.0

This commit is contained in:
Oskar Wickström 2017-01-11 21:19:08 +01:00
parent 9ae690ba2a
commit afba2ed2d1
5 changed files with 40 additions and 30 deletions

View File

@ -19,6 +19,6 @@
"purescript-console": "^2.0.0", "purescript-console": "^2.0.0",
"purescript-foldable-traversable": "^2.0.0", "purescript-foldable-traversable": "^2.0.0",
"purescript-exceptions": "~2.0.0", "purescript-exceptions": "~2.0.0",
"purescript-spec": "^0.10.0" "purescript-spec": "^0.11.0"
} }
} }

View File

@ -33,7 +33,7 @@ module.exports = function(config) {
// test results reporter to use // test results reporter to use
// possible values: 'dots', 'progress' // possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter // available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'bdd'], reporters: ['progress'],
// web server port // web server port

View File

@ -2,21 +2,24 @@
// module Test.Spec.Mocha // module Test.Spec.Mocha
if (!describe || !it) { if (typeof describe !== 'function' || typeof it !== 'function') {
throw new Error('Mocha globals seem to be unavailable!'); throw new Error('Mocha globals seem to be unavailable!');
} }
exports.itAsync = function (name) { exports.itAsync = function (only) {
"use strict"; "use strict";
return function (name) {
return function (aff) { return function (aff) {
return function () { return function () {
it(name, function (done) { var f = only ? it.only : it;
f(name, function (done) {
aff(function () { aff(function () {
done(); done();
}, function (err) { }, function (err) {
done(err); done(err);
})
}); });
});
};
}; };
}; };
}; };
@ -28,13 +31,16 @@ exports.itPending = function (name) {
}; };
}; };
exports.describe = function (name) { exports.describe = function (only) {
"use strict"; "use strict";
return function (name) {
return function (nested) { return function (nested) {
return function () { return function () {
describe(name, function () { var f = only ? describe : describe.only;
f(name, function () {
nested(); nested();
}); });
}; };
}; };
}; };
};

View File

@ -14,23 +14,27 @@ import Test.Spec (Spec, Group(..), collect)
foreign import data MOCHA :: ! foreign import data MOCHA :: !
foreign import itAsync :: forall e. String foreign import itAsync :: forall e.
Boolean
-> String
-> Aff e Unit -> Aff e Unit
-> Eff (mocha :: MOCHA | e) Unit -> Eff (mocha :: MOCHA | e) Unit
foreign import itPending :: forall e. String foreign import itPending :: forall e. String
-> Eff (mocha :: MOCHA | e) Unit -> 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
-> Eff (mocha :: MOCHA | e) Unit -> Eff (mocha :: MOCHA | e) Unit
registerGroup :: forall e. (Group (Aff e Unit)) registerGroup :: forall e. (Group (Aff e Unit))
-> Eff (mocha :: MOCHA | 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 (Pending name) = itPending name
registerGroup (Describe name groups) = registerGroup (Describe only name groups) =
describe name (traverse_ registerGroup groups) describe only name (traverse_ registerGroup groups)
runMocha :: forall e. Spec e Unit runMocha :: forall e. Spec e Unit
-> Eff (mocha :: MOCHA | e) Unit -> Eff (mocha :: MOCHA | e) Unit

View File

@ -1,13 +1,13 @@
module Test.Main where module Test.Main where
import Prelude import Prelude
import Control.Monad.Aff (later') import Control.Monad.Aff (later')
import Control.Monad.Eff (Eff)
import Test.Spec (describe, it, pending) import Test.Spec (SpecEffects, describe, it, pending)
import Test.Spec.Assertions (shouldEqual) 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 main = runMocha do
describe "test" $ describe "test" $
describe "nested" do describe "nested" do