[ospec] Allow more than one o.only() test
This commit is contained in:
parent
a23216b987
commit
14695c9cda
2 changed files with 10 additions and 4 deletions
|
|
@ -4,7 +4,7 @@
|
||||||
if (typeof module !== "undefined") module["exports"] = m()
|
if (typeof module !== "undefined") module["exports"] = m()
|
||||||
else window.o = m()
|
else window.o = m()
|
||||||
})(function init(name) {
|
})(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 = [], ctx = spec, start, stack = 0, nextTickish, hasProcess = typeof process === "object", hasOwn = ({}).hasOwnProperty
|
||||||
var ospecFileName = getStackName(ensureStackTrace(new Error), /[\/\\](.*?):\d+:\d+/), timeoutStackName
|
var ospecFileName = getStackName(ensureStackTrace(new Error), /[\/\\](.*?):\d+:\d+/), timeoutStackName
|
||||||
var globalTimeout = noTimeoutRightNow
|
var globalTimeout = noTimeoutRightNow
|
||||||
var currentTestError = null
|
var currentTestError = null
|
||||||
|
|
@ -43,7 +43,8 @@ else window.o = m()
|
||||||
highlight("/!\\ WARNING /!\\ o.only() mode") + "\n" + o.cleanStackTrace(ensureStackTrace(new Error)) + "\n",
|
highlight("/!\\ WARNING /!\\ o.only() mode") + "\n" + o.cleanStackTrace(ensureStackTrace(new Error)) + "\n",
|
||||||
cStyle("red"), ""
|
cStyle("red"), ""
|
||||||
)
|
)
|
||||||
o(subject, only = predicate)
|
only.push(predicate)
|
||||||
|
o(subject, predicate)
|
||||||
}
|
}
|
||||||
o.spy = function(fn) {
|
o.spy = function(fn) {
|
||||||
var spy = function() {
|
var spy = function() {
|
||||||
|
|
@ -101,7 +102,7 @@ else window.o = m()
|
||||||
pre = [].concat(pre, spec["\x01beforeEach"] || [])
|
pre = [].concat(pre, spec["\x01beforeEach"] || [])
|
||||||
post = [].concat(spec["\x01afterEach"] || [], post)
|
post = [].concat(spec["\x01afterEach"] || [], post)
|
||||||
series([].concat(spec["\x01before"] || [], Object.keys(spec).reduce(function(tasks, key) {
|
series([].concat(spec["\x01before"] || [], Object.keys(spec).reduce(function(tasks, key) {
|
||||||
if (key.charCodeAt(0) !== 1 && (only === null || spec[key].fn === only || !(spec[key] instanceof Task))) {
|
if (key.charCodeAt(0) !== 1 && (only.length === 0 || only.indexOf(spec[key].fn) !== -1 || !(spec[key] instanceof Task))) {
|
||||||
tasks.push(new Task(function(done) {
|
tasks.push(new Task(function(done) {
|
||||||
o.timeout(Infinity)
|
o.timeout(Infinity)
|
||||||
subjects.push(key)
|
subjects.push(key)
|
||||||
|
|
|
||||||
|
|
@ -50,11 +50,16 @@ o("o.only", function(done) {
|
||||||
oo.only(".only()", function() {
|
oo.only(".only()", function() {
|
||||||
oo(2).equals(2)
|
oo(2).equals(2)
|
||||||
}, true)
|
}, true)
|
||||||
|
oo.only("another .only()", function(done) {
|
||||||
|
done("that fails")
|
||||||
|
}, true)
|
||||||
})
|
})
|
||||||
|
|
||||||
oo.run(function(results){
|
oo.run(function(results){
|
||||||
o(results.length).equals(1)
|
o(results.length).equals(2)
|
||||||
o(results[0].pass).equals(true)
|
o(results[0].pass).equals(true)
|
||||||
|
o(results[1].pass).equals(false)
|
||||||
|
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue