[ospec] Add the possibility to name new test suites
This commit is contained in:
parent
301785b1a5
commit
2c2ca73c22
1 changed files with 4 additions and 1 deletions
|
|
@ -1,8 +1,10 @@
|
||||||
"use strict"
|
"use strict"
|
||||||
|
|
||||||
module.exports = new function init() {
|
module.exports = new function init(name) {
|
||||||
var spec = {}, subjects = [], results = [], only = null, ctx = spec, start, stack = 0, nextTickish, hasProcess = typeof process === "object", hasOwn = ({}).hasOwnProperty
|
var spec = {}, subjects = [], results = [], only = null, ctx = spec, start, stack = 0, nextTickish, hasProcess = typeof process === "object", hasOwn = ({}).hasOwnProperty
|
||||||
|
|
||||||
|
if (name != null) spec[name] = ctx = {}
|
||||||
|
|
||||||
function o(subject, predicate) {
|
function o(subject, predicate) {
|
||||||
if (predicate === undefined) return new Assert(subject)
|
if (predicate === undefined) return new Assert(subject)
|
||||||
ctx[unique(subject)] = predicate
|
ctx[unique(subject)] = predicate
|
||||||
|
|
@ -210,6 +212,7 @@ module.exports = new function init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
console.log(
|
console.log(
|
||||||
|
(name ? name + ": " : "") +
|
||||||
results.length + " assertions completed in " + Math.round(new Date - start) + "ms, " +
|
results.length + " assertions completed in " + Math.round(new Date - start) + "ms, " +
|
||||||
"of which " + results.filter(function(result){return result.error}).length + " failed"
|
"of which " + results.filter(function(result){return result.error}).length + " failed"
|
||||||
)
|
)
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue