"use strict" and other linty fixes
This commit is contained in:
parent
aaa6de784b
commit
1cc5fa5ba7
50 changed files with 463 additions and 478 deletions
|
|
@ -17,7 +17,7 @@ o.spec("browserMock", function() {
|
|||
})
|
||||
o("$window.onhashchange can be reached from the pushStateMock functions", function(done) {
|
||||
$window.onhashchange = o.spy()
|
||||
$window.location.hash = '#a'
|
||||
$window.location.hash = "#a"
|
||||
|
||||
callAsync(function(){
|
||||
o($window.onhashchange.callCount).equals(1)
|
||||
|
|
@ -33,7 +33,7 @@ o.spec("browserMock", function() {
|
|||
})
|
||||
o("$window.onunload can be reached from the pushStateMock functions", function() {
|
||||
$window.onunload = o.spy()
|
||||
$window.location.href = '/a'
|
||||
$window.location.href = "/a"
|
||||
|
||||
o($window.onunload.callCount).equals(1)
|
||||
})
|
||||
|
|
|
|||
|
|
@ -6,8 +6,8 @@ var components = require("../../test-utils/components")
|
|||
o.spec("test-utils/components", function() {
|
||||
var test = o.spy(function(component) {
|
||||
return function() {
|
||||
o('works', function() {
|
||||
o(typeof component.kind).equals('string')
|
||||
o("works", function() {
|
||||
o(typeof component.kind).equals("string")
|
||||
|
||||
var methods = {oninit: function(){}, view: function(){}}
|
||||
|
||||
|
|
@ -21,7 +21,7 @@ o.spec("test-utils/components", function() {
|
|||
cmp2 = new (component.create(methods))
|
||||
} else if (component.kind === "closure") {
|
||||
cmp1 = component.create()()
|
||||
cmp2 = component.create(methods)()
|
||||
cmp2 = component.create(methods)()
|
||||
} else {
|
||||
throw new Error("unexpected component kind")
|
||||
}
|
||||
|
|
@ -34,7 +34,7 @@ o.spec("test-utils/components", function() {
|
|||
o(vnode != null).equals(true)
|
||||
o(vnode).deepEquals({tag: "div"})
|
||||
|
||||
if (component.kind !== 'constructible') {
|
||||
if (component.kind !== "constructible") {
|
||||
o(cmp2).deepEquals(methods)
|
||||
} else {
|
||||
// deepEquals doesn't search the prototype, do it manually
|
||||
|
|
|
|||
|
|
@ -321,7 +321,7 @@ o.spec("domMock", function() {
|
|||
o(div.getAttribute("id")).equals("aaa")
|
||||
})
|
||||
})
|
||||
|
||||
|
||||
o.spec("setAttribute", function() {
|
||||
o("works", function() {
|
||||
var div = $document.createElement("div")
|
||||
|
|
@ -393,7 +393,6 @@ o.spec("domMock", function() {
|
|||
o.spec("textContent", function() {
|
||||
o("works", function() {
|
||||
var div = $document.createElement("div")
|
||||
var a = $document.createElement("a")
|
||||
div.textContent = "aaa"
|
||||
|
||||
o(div.childNodes.length).equals(1)
|
||||
|
|
@ -402,7 +401,6 @@ o.spec("domMock", function() {
|
|||
})
|
||||
o("works with empty string", function() {
|
||||
var div = $document.createElement("div")
|
||||
var a = $document.createElement("a")
|
||||
div.textContent = ""
|
||||
|
||||
o(div.childNodes.length).equals(0)
|
||||
|
|
@ -514,8 +512,8 @@ o.spec("domMock", function() {
|
|||
var div = $document.createElement("div")
|
||||
div.style.cssText = "background: url(';'); font-family: \";\""
|
||||
|
||||
o(div.style.background).equals("url(';')")
|
||||
o(div.style.fontFamily).equals("\";\"")
|
||||
o(div.style.background).equals("url(';')")
|
||||
o(div.style.fontFamily).equals('";"')
|
||||
o(div.style.cssText).equals("background: url(';'); font-family: \";\";")
|
||||
})
|
||||
o("comments in style.cssText are stripped", function(){
|
||||
|
|
@ -534,9 +532,10 @@ o.spec("domMock", function() {
|
|||
|
||||
})
|
||||
o("setting style throws", function () {
|
||||
var div = $document.createElement("div")
|
||||
var err = false
|
||||
try {
|
||||
div.style = ''
|
||||
div.style = ""
|
||||
} catch (e) {
|
||||
err = e
|
||||
}
|
||||
|
|
@ -919,55 +918,55 @@ o.spec("domMock", function() {
|
|||
o.spec("canvas width and height", function() {
|
||||
o("setting property works", function() {
|
||||
var canvas = $document.createElement("canvas")
|
||||
|
||||
|
||||
canvas.width = 100
|
||||
o(canvas.attributes["width"].nodeValue).equals("100")
|
||||
o(canvas.width).equals(100)
|
||||
|
||||
|
||||
canvas.height = 100
|
||||
o(canvas.attributes["height"].nodeValue).equals("100")
|
||||
o(canvas.height).equals(100)
|
||||
})
|
||||
o("setting string casts to number", function() {
|
||||
var canvas = $document.createElement("canvas")
|
||||
|
||||
|
||||
canvas.width = "100"
|
||||
o(canvas.attributes["width"].nodeValue).equals("100")
|
||||
o(canvas.width).equals(100)
|
||||
|
||||
|
||||
canvas.height = "100"
|
||||
o(canvas.attributes["height"].nodeValue).equals("100")
|
||||
o(canvas.height).equals(100)
|
||||
})
|
||||
o("setting float casts to int", function() {
|
||||
var canvas = $document.createElement("canvas")
|
||||
|
||||
|
||||
canvas.width = 1.2
|
||||
o(canvas.attributes["width"].nodeValue).equals("1")
|
||||
o(canvas.width).equals(1)
|
||||
|
||||
|
||||
canvas.height = 1.2
|
||||
o(canvas.attributes["height"].nodeValue).equals("1")
|
||||
o(canvas.height).equals(1)
|
||||
})
|
||||
o("setting percentage fails", function() {
|
||||
var canvas = $document.createElement("canvas")
|
||||
|
||||
|
||||
canvas.width = "100%"
|
||||
o(canvas.attributes["width"].nodeValue).equals("0")
|
||||
o(canvas.width).equals(0)
|
||||
|
||||
|
||||
canvas.height = "100%"
|
||||
o(canvas.attributes["height"].nodeValue).equals("0")
|
||||
o(canvas.height).equals(0)
|
||||
})
|
||||
o("setting attribute works", function() {
|
||||
var canvas = $document.createElement("canvas")
|
||||
|
||||
|
||||
canvas.setAttribute("width", "100%")
|
||||
o(canvas.attributes["width"].nodeValue).equals("100%")
|
||||
o(canvas.width).equals(100)
|
||||
|
||||
|
||||
canvas.setAttribute("height", "100%")
|
||||
o(canvas.attributes["height"].nodeValue).equals("100%")
|
||||
o(canvas.height).equals(100)
|
||||
|
|
|
|||
|
|
@ -168,13 +168,13 @@ o.spec("pushStateMock", function() {
|
|||
})
|
||||
o.spec("set protocol", function() {
|
||||
o("setting protocol throws", function(done) {
|
||||
var old = $window.location.href
|
||||
try {
|
||||
$window.location.protocol = "https://"
|
||||
}
|
||||
catch (e) {
|
||||
done()
|
||||
return done()
|
||||
}
|
||||
throw new Error("Expected an error")
|
||||
})
|
||||
})
|
||||
o.spec("set port", function() {
|
||||
|
|
@ -413,17 +413,17 @@ o.spec("pushStateMock", function() {
|
|||
})
|
||||
o("replaceState does not break forward history", function() {
|
||||
$window.onpopstate = o.spy()
|
||||
|
||||
|
||||
$window.history.pushState(null, null, "b")
|
||||
$window.history.back()
|
||||
|
||||
o($window.onpopstate.callCount).equals(1)
|
||||
o($window.location.href).equals("http://localhost/")
|
||||
|
||||
|
||||
$window.history.replaceState(null, null, "a")
|
||||
|
||||
|
||||
o($window.location.href).equals("http://localhost/a")
|
||||
|
||||
|
||||
$window.history.forward()
|
||||
|
||||
o($window.onpopstate.callCount).equals(2)
|
||||
|
|
@ -431,46 +431,46 @@ o.spec("pushStateMock", function() {
|
|||
})
|
||||
o("pushstate retains state", function() {
|
||||
$window.onpopstate = o.spy()
|
||||
|
||||
|
||||
$window.history.pushState({a: 1}, null, "#a")
|
||||
$window.history.pushState({b: 2}, null, "#b")
|
||||
|
||||
|
||||
o($window.onpopstate.callCount).equals(0)
|
||||
|
||||
$window.history.back()
|
||||
|
||||
|
||||
o($window.onpopstate.callCount).equals(1)
|
||||
o($window.onpopstate.args[0].type).equals("popstate")
|
||||
o($window.onpopstate.args[0].state).deepEquals({a: 1})
|
||||
|
||||
$window.history.back()
|
||||
|
||||
|
||||
o($window.onpopstate.callCount).equals(2)
|
||||
o($window.onpopstate.args[0].type).equals("popstate")
|
||||
o($window.onpopstate.args[0].state).equals(null)
|
||||
|
||||
$window.history.forward()
|
||||
|
||||
|
||||
o($window.onpopstate.callCount).equals(3)
|
||||
o($window.onpopstate.args[0].type).equals("popstate")
|
||||
o($window.onpopstate.args[0].state).deepEquals({a: 1})
|
||||
|
||||
$window.history.forward()
|
||||
|
||||
|
||||
o($window.onpopstate.callCount).equals(4)
|
||||
o($window.onpopstate.args[0].type).equals("popstate")
|
||||
o($window.onpopstate.args[0].state).deepEquals({b: 2})
|
||||
})
|
||||
o("replacestate replaces state", function() {
|
||||
$window.onpopstate = o.spy(pop)
|
||||
|
||||
|
||||
$window.history.replaceState({a: 1}, null, "a")
|
||||
|
||||
|
||||
o($window.history.state).deepEquals({a: 1})
|
||||
|
||||
|
||||
$window.history.pushState(null, null, "a")
|
||||
$window.history.back()
|
||||
|
||||
|
||||
function pop(e) {
|
||||
o(e.state).deepEquals({a: 1})
|
||||
o($window.history.state).deepEquals({a: 1})
|
||||
|
|
|
|||
|
|
@ -5,13 +5,13 @@ var xhrMock = require("../../test-utils/xhrMock")
|
|||
var parseQueryString = require("../../querystring/parse")
|
||||
|
||||
o.spec("xhrMock", function() {
|
||||
var $window, ajax
|
||||
var $window
|
||||
o.beforeEach(function() {
|
||||
$window = xhrMock()
|
||||
})
|
||||
|
||||
o.spec("xhr", function() {
|
||||
o("works", function(done, timeout) {
|
||||
o("works", function(done) {
|
||||
$window.$defineRoutes({
|
||||
"GET /item": function(request) {
|
||||
o(request.url).equals("/item")
|
||||
|
|
@ -29,7 +29,7 @@ o.spec("xhrMock", function() {
|
|||
}
|
||||
xhr.send()
|
||||
})
|
||||
o("works w/ search", function(done, timeout) {
|
||||
o("works w/ search", function(done) {
|
||||
$window.$defineRoutes({
|
||||
"GET /item": function(request) {
|
||||
o(request.query).equals("?a=b")
|
||||
|
|
@ -45,7 +45,7 @@ o.spec("xhrMock", function() {
|
|||
}
|
||||
xhr.send()
|
||||
})
|
||||
o("works w/ body", function(done, timeout) {
|
||||
o("works w/ body", function(done) {
|
||||
$window.$defineRoutes({
|
||||
"POST /item": function(request) {
|
||||
o(request.body).equals("a=b")
|
||||
|
|
@ -61,7 +61,7 @@ o.spec("xhrMock", function() {
|
|||
}
|
||||
xhr.send("a=b")
|
||||
})
|
||||
o("handles routing error", function(done, timeout) {
|
||||
o("handles routing error", function(done) {
|
||||
var xhr = new $window.XMLHttpRequest()
|
||||
xhr.open("GET", "/nonexistent")
|
||||
xhr.onreadystatechange = function() {
|
||||
|
|
@ -113,7 +113,7 @@ o.spec("xhrMock", function() {
|
|||
done()
|
||||
}
|
||||
})
|
||||
o("works with other querystring params", function(done, timeout) {
|
||||
o("works with other querystring params", function(done) {
|
||||
$window.$defineRoutes({
|
||||
"GET /test": function(request) {
|
||||
var queryData = parseQueryString(request.query)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue