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-foldable-traversable": "^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
// possible values: 'dots', 'progress'
// available reporters: https://npmjs.org/browse/keyword/karma-reporter
reporters: ['progress', 'bdd'],
reporters: ['progress'],
// web server port

View File

@ -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();
});
};
};
};
};

View File

@ -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

View File

@ -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