#1520 ospec: report duplicate test names
This commit is contained in:
parent
3bac29bf78
commit
9ad16858a5
9 changed files with 16 additions and 61 deletions
|
|
@ -1074,43 +1074,6 @@ o.spec("route", function() {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
o("calling route.set invalidates pending onmatch resolution", function(done) {
|
|
||||||
var rendered = false
|
|
||||||
var resolved
|
|
||||||
$window.location.href = prefix + "/a"
|
|
||||||
route(root, "/a", {
|
|
||||||
"/a": {
|
|
||||||
onmatch: function() {
|
|
||||||
return new Promise(function(resolve) {
|
|
||||||
callAsync(function() {
|
|
||||||
callAsync(function() {
|
|
||||||
resolve({view: function() {}})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
})
|
|
||||||
},
|
|
||||||
render: function(vnode) {
|
|
||||||
rendered = true
|
|
||||||
resolved = "a"
|
|
||||||
}
|
|
||||||
},
|
|
||||||
"/b": {
|
|
||||||
view: function() {
|
|
||||||
resolved = "b"
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
route.set("/b")
|
|
||||||
|
|
||||||
callAsync(function() {
|
|
||||||
o(rendered).equals(false)
|
|
||||||
o(resolved).equals("b")
|
|
||||||
|
|
||||||
done()
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
o("calling route.set invalidates pending onmatch resolution", function(done) {
|
o("calling route.set invalidates pending onmatch resolution", function(done) {
|
||||||
var rendered = false
|
var rendered = false
|
||||||
var resolved
|
var resolved
|
||||||
|
|
|
||||||
|
|
@ -214,14 +214,14 @@ o.spec("bundler", function() {
|
||||||
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
||||||
bundle(ns + "a.js", ns + "out.js")
|
bundle(ns + "a.js", ns + "out.js")
|
||||||
|
|
||||||
o(read("out.js")).equals(`new function() {\nvar x = {}\var bb = 1\nnx.b = bb\nvar cc = 1\nx.c = cc\n}`)
|
o(read("out.js")).equals(`new function() {\nvar x = {}\nvar bb = 1\nx.b = bb\nvar cc = 2\nx.c = cc\n}`)
|
||||||
|
|
||||||
remove("a.js")
|
remove("a.js")
|
||||||
remove("b.js")
|
remove("b.js")
|
||||||
remove("c.js")
|
remove("c.js")
|
||||||
remove("out.js")
|
remove("out.js")
|
||||||
})
|
})
|
||||||
o("works if assigned to property", function() {
|
o("works if assigned to property using bracket notation", function() {
|
||||||
write("a.js", `var x = {}\nx["b"] = require("./b")\nx["c"] = require("./c")`)
|
write("a.js", `var x = {}\nx["b"] = require("./b")\nx["c"] = require("./c")`)
|
||||||
write("b.js", `var bb = 1\nmodule.exports = bb`)
|
write("b.js", `var bb = 1\nmodule.exports = bb`)
|
||||||
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
write("c.js", `var cc = 2\nmodule.exports = cc`)
|
||||||
|
|
|
||||||
|
|
@ -4,7 +4,7 @@
|
||||||
|
|
||||||
Noiseless testing framework
|
Noiseless testing framework
|
||||||
|
|
||||||
Version: 1.2.2
|
Version: 1.2.3
|
||||||
License: MIT
|
License: MIT
|
||||||
|
|
||||||
## About
|
## About
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,7 @@ module.exports = new function init() {
|
||||||
var spec = {}, subjects = [], results = [], only = null, ctx = spec, start, stack = 0, hasProcess = typeof process === "object"
|
var spec = {}, subjects = [], results = [], only = null, ctx = spec, start, stack = 0, hasProcess = typeof process === "object"
|
||||||
|
|
||||||
function o(subject, predicate) {
|
function o(subject, predicate) {
|
||||||
|
subject = unique(subject, predicate)
|
||||||
ctx[subject] = predicate
|
ctx[subject] = predicate
|
||||||
if (predicate === undefined) return new Assert(subject)
|
if (predicate === undefined) return new Assert(subject)
|
||||||
}
|
}
|
||||||
|
|
@ -14,6 +15,7 @@ module.exports = new function init() {
|
||||||
o.new = init
|
o.new = init
|
||||||
o.spec = function(subject, predicate) {
|
o.spec = function(subject, predicate) {
|
||||||
var parent = ctx
|
var parent = ctx
|
||||||
|
subject = unique(subject, predicate)
|
||||||
ctx = ctx[subject] = {}
|
ctx = ctx[subject] = {}
|
||||||
predicate()
|
predicate()
|
||||||
ctx = parent
|
ctx = parent
|
||||||
|
|
@ -110,6 +112,13 @@ module.exports = new function init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
function unique(subject, predicate) {
|
||||||
|
if (ctx.hasOwnProperty(subject) && predicate) {
|
||||||
|
console.warn("A test named `" + subject + "` was already defined")
|
||||||
|
subject = subject + "*"
|
||||||
|
}
|
||||||
|
return subject
|
||||||
|
}
|
||||||
function hook(name) {
|
function hook(name) {
|
||||||
return function(predicate) {
|
return function(predicate) {
|
||||||
if (ctx[name]) throw new Error("This hook should be defined outside of a loop or inside a nested test group:\n" + predicate)
|
if (ctx[name]) throw new Error("This hook should be defined outside of a loop or inside a nested test group:\n" + predicate)
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
{
|
{
|
||||||
"name": "ospec",
|
"name": "ospec",
|
||||||
"version": "1.2.2",
|
"version": "1.2.3",
|
||||||
"description": "Noiseless testing framework",
|
"description": "Noiseless testing framework",
|
||||||
"main": "ospec.js",
|
"main": "ospec.js",
|
||||||
"directories": {
|
"directories": {
|
||||||
|
|
|
||||||
|
|
@ -27,7 +27,7 @@ o.spec("promise", function() {
|
||||||
|
|
||||||
o(promise instanceof Promise).equals(true)
|
o(promise instanceof Promise).equals(true)
|
||||||
})
|
})
|
||||||
o("static resolve returns promise", function() {
|
o("static reject returns promise", function() {
|
||||||
var promise = Promise.reject()
|
var promise = Promise.reject()
|
||||||
promise.catch(function() {})
|
promise.catch(function() {})
|
||||||
|
|
||||||
|
|
@ -141,7 +141,7 @@ o.spec("promise", function() {
|
||||||
done()
|
done()
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
o("non-function onFulfilled is ignored", function(done) {
|
o("non-function onFulfilled with no second param is ignored", function(done) {
|
||||||
var promise = Promise.resolve(1)
|
var promise = Promise.resolve(1)
|
||||||
|
|
||||||
promise.then(null).then(function(value) {
|
promise.then(null).then(function(value) {
|
||||||
|
|
|
||||||
|
|
@ -64,17 +64,6 @@ o.spec("jsonp", function() {
|
||||||
o(data).deepEquals({a: 2})
|
o(data).deepEquals({a: 2})
|
||||||
}).then(done)
|
}).then(done)
|
||||||
})
|
})
|
||||||
o("works w/ custom callbackKey", function(done) {
|
|
||||||
mock.$defineRoutes({
|
|
||||||
"GET /item": function(request) {
|
|
||||||
var queryData = parseQueryString(request.query)
|
|
||||||
return {status: 200, responseText: queryData["cb"] + "(" + JSON.stringify({a: 2}) + ")"}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
jsonp({url: "/item", callbackKey: "cb"}).then(function(data) {
|
|
||||||
o(data).deepEquals({a: 2})
|
|
||||||
}).then(done)
|
|
||||||
})
|
|
||||||
o("requests don't block each other", function(done) {
|
o("requests don't block each other", function(done) {
|
||||||
mock.$defineRoutes({
|
mock.$defineRoutes({
|
||||||
"GET /item": function(request) {
|
"GET /item": function(request) {
|
||||||
|
|
|
||||||
|
|
@ -136,7 +136,7 @@ o.spec("parseURL", function() {
|
||||||
o(data.search).equals("?a/c")
|
o(data.search).equals("?a/c")
|
||||||
o(data.hash).equals("")
|
o(data.hash).equals("")
|
||||||
})
|
})
|
||||||
o("handles search w/ slash", function() {
|
o("handles search w/ colon", function() {
|
||||||
var data = parseURL("http://www.google.com/test?a:c")
|
var data = parseURL("http://www.google.com/test?a:c")
|
||||||
o(data.pathname).equals("/test")
|
o(data.pathname).equals("/test")
|
||||||
o(data.search).equals("?a:c")
|
o(data.search).equals("?a:c")
|
||||||
|
|
|
||||||
|
|
@ -382,12 +382,6 @@ o.spec("pushStateMock", function() {
|
||||||
|
|
||||||
o($window.onpopstate.callCount).equals(2)
|
o($window.onpopstate.callCount).equals(2)
|
||||||
})
|
})
|
||||||
o("history.back() without history does not trigger onpopstate", function() {
|
|
||||||
$window.onpopstate = o.spy()
|
|
||||||
$window.history.back()
|
|
||||||
|
|
||||||
o($window.onpopstate.callCount).equals(0)
|
|
||||||
})
|
|
||||||
o("history.forward() without history does not trigger onpopstate", function() {
|
o("history.forward() without history does not trigger onpopstate", function() {
|
||||||
$window.onpopstate = o.spy()
|
$window.onpopstate = o.spy()
|
||||||
$window.history.forward()
|
$window.history.forward()
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue