mirror of
https://github.com/ilyakooo0/purescript-spec-mocha.git
synced 2024-11-28 23:13:20 +03:00
Adapt to purescript-spec-0.11.0
This commit is contained in:
parent
9ae690ba2a
commit
afba2ed2d1
@ -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"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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
|
||||||
|
@ -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 (aff) {
|
return function (name) {
|
||||||
return function () {
|
return function (aff) {
|
||||||
it(name, function (done) {
|
return function () {
|
||||||
aff(function () {
|
var f = only ? it.only : it;
|
||||||
done();
|
f(name, function (done) {
|
||||||
}, function (err) {
|
aff(function () {
|
||||||
done(err);
|
done();
|
||||||
})
|
}, function (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 (nested) {
|
return function (name) {
|
||||||
return function () {
|
return function (nested) {
|
||||||
describe(name, function () {
|
return function () {
|
||||||
nested();
|
var f = only ? describe : describe.only;
|
||||||
});
|
f(name, function () {
|
||||||
|
nested();
|
||||||
|
});
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
|
@ -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.
|
||||||
-> Aff e Unit
|
Boolean
|
||||||
-> Eff (mocha :: MOCHA | e) Unit
|
-> String
|
||||||
|
-> Aff 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
|
||||||
|
@ -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
|
||||||
|
Loading…
Reference in New Issue
Block a user