Code style cleanup, remove redundant comments

This commit is contained in:
Robin North
2018-01-31 22:17:06 +00:00
parent 9971c4c4f0
commit 1eb43f73fe
15 changed files with 87 additions and 120 deletions

View File

@@ -7,8 +7,7 @@ var trigger = require("../../lib/events/trigger")
var el = document.createElement("div")
var el2 = document.createElement("span")
var els = [el, el2]
// var eventType2 = "resize"
// var eventsType = "click resize"
var classCb = function() {
this.className += "on"
}
@@ -92,14 +91,14 @@ tape("test events on/off/trigger for multiple elements, multiple events", functi
})
tape("test events on top level elements", function(t) {
var el = document;
var el = document
el.className = ""
on(el, "click", classCb)
trigger(el, "click")
t.equal(el.className, "on", "attached callback has been fired properly on document")
el = window;
el = window
el.className = ""
// With jsdom, the default this is global, not window, so we need to explicitly bind to window.

View File

@@ -91,5 +91,5 @@ tape("test options are not modified by attachForm", function(t) {
t.equal(1, Object.keys(options).length, "options object that is passed in should not be modified")
t.equal("bar", options.foo, "options object that is passed in should not be modified")
t.end();
t.end()
})

View File

@@ -79,7 +79,7 @@ tape("test attach link preventDefaulted events", function(t) {
tape("test options are not modified by attachLink", function(t) {
var a = document.createElement("a")
var options = {foo: "bar"}
var loadUrl = function() {};
var loadUrl = function() {}
attachLink.call({options: options, loadUrl: loadUrl}, a)
@@ -90,5 +90,5 @@ tape("test options are not modified by attachLink", function(t) {
t.equal(1, Object.keys(options).length, "options object that is passed in should not be modified")
t.equal("bar", options.foo, "options object that is passed in should not be modified")
t.end();
t.end()
})

View File

@@ -3,46 +3,46 @@ var tape = require("tape")
var parseOptions = require("../../../lib/proto/parse-options.js")
tape("test parse initalization options function", function(t) {
t.test("- default options", function(t) {
var pjax = {};
parseOptions.call(pjax, {});
var pjax = {}
parseOptions.call(pjax, {})
t.equal(pjax.options.elements, "a[href], form[action]");
t.equal(pjax.options.selectors.length, 2, "selectors length");
t.equal(pjax.options.selectors[0], "title");
t.equal(pjax.options.selectors[1], ".js-Pjax");
t.equal(pjax.options.elements, "a[href], form[action]")
t.equal(pjax.options.selectors.length, 2, "selectors length")
t.equal(pjax.options.selectors[0], "title")
t.equal(pjax.options.selectors[1], ".js-Pjax")
t.equal(typeof pjax.options.switches, "object");
t.equal(Object.keys(pjax.options.switches).length, 2);// head and body
t.equal(typeof pjax.options.switches, "object")
t.equal(Object.keys(pjax.options.switches).length, 2)// head and body
t.equal(typeof pjax.options.switchesOptions, "object");
t.equal(Object.keys(pjax.options.switchesOptions).length, 0);
t.equal(typeof pjax.options.switchesOptions, "object")
t.equal(Object.keys(pjax.options.switchesOptions).length, 0)
t.equal(pjax.options.history, true);
t.equal(typeof pjax.options.analytics, "function");
t.equal(pjax.options.scrollTo, 0);
t.equal(pjax.options.scrollRestoration, true);
t.equal(pjax.options.cacheBust, true);
t.equal(pjax.options.debug, false);
t.end();
});
t.equal(pjax.options.history, true)
t.equal(typeof pjax.options.analytics, "function")
t.equal(pjax.options.scrollTo, 0)
t.equal(pjax.options.scrollRestoration, true)
t.equal(pjax.options.cacheBust, true)
t.equal(pjax.options.debug, false)
t.end()
})
// verify analytics always ends up as a function even when passed not a function
t.test("- analytics is a function", function(t) {
var pjax = {};
parseOptions.call(pjax, {analytics: "some string"});
var pjax = {}
parseOptions.call(pjax, {analytics: "some string"})
t.deepEqual(typeof pjax.options.analytics, "function");
t.end();
});
t.deepEqual(typeof pjax.options.analytics, "function")
t.end()
})
// verify that the value false for scrollTo is not squashed
t.test("- scrollTo remains false", function(t) {
var pjax = {};
parseOptions.call(pjax, {scrollTo: false});
var pjax = {}
parseOptions.call(pjax, {scrollTo: false})
t.deepEqual(pjax.options.scrollTo, false);
t.end();
});
t.deepEqual(pjax.options.scrollTo, false)
t.end()
})
t.end()
})

View File

@@ -22,7 +22,7 @@ tape("test xhr request", function(t) {
options: {
cacheBust: true
}
});
})
var r = requestCacheBust(url, {}, function(result) {
t.equal(r.responseURL.indexOf("?"), url.length, "XHR URL is cache-busted when configured to be")
try {
@@ -40,7 +40,7 @@ tape("test xhr request", function(t) {
options: {
cacheBust: false
}
});
})
var r = requestNoCacheBust(url, {}, function() {
t.equal(r.responseURL, url, "XHR URL is left untouched")
t.end()