Fix linting errors

This commit is contained in:
Behind The Math
2018-01-09 00:44:20 -05:00
committed by BehindTheMath
parent e586440964
commit c0d64e41b8
8 changed files with 95 additions and 90 deletions

View File

@@ -46,12 +46,12 @@ tape("test attach form prototype method", function(t) {
// see reload defined above
form.action = window.location.protocol + "//" + window.location.host + "/internal"
form.method = 'POST'
form.method = "POST"
trigger(form, "submit")
// see post defined above
form.action = window.location.protocol + "//" + window.location.host + "/internal"
form.method = 'GET'
form.method = "GET"
trigger(form, "submit")
// see post defined above

View File

@@ -4,70 +4,75 @@ var parseOptions = require("../../../lib/proto/parse-options.js")
tape("test parse initalization options function", function(t) {
// via http://stackoverflow.com/questions/1173549/how-to-determine-if-an-object-is-an-object-literal-in-javascript
function isObjLiteral(_obj) {
var _test = _obj;
return ( typeof _obj !== 'object' || _obj === null ?
false :
(
(function () {
while (!false) {
if ( Object.getPrototypeOf( _test = Object.getPrototypeOf(_test) ) === null) {
break;
}
}
return Object.getPrototypeOf(_obj) === _test;
})()
)
var _test = _obj;
return (typeof _obj !== "object" || _obj === null ?
false :
(
(function() {
while (!false) {
if (Object.getPrototypeOf(_test = Object.getPrototypeOf(_test)) === null) {
break;
}
}
return Object.getPrototypeOf(_obj) === _test;
})()
)
);
}
function enumerableKeys(_obj) {
var c = 0;
for(var n in _obj){ n = n; c++; }
for (var n in _obj) {
n = n;
c++;
}
return c;
}
t.test("- default options", function(t){
var body_1 = {};
var options_1 = {};
parseOptions.apply(body_1,[options_1]);
t.deepEqual(body_1.options.elements,"a[href], form[action]");
t.deepEqual(body_1.options.selectors.length,2,"selectors length");
t.deepEqual(body_1.options.selectors[0],"title");
t.deepEqual(body_1.options.selectors[1],".js-Pjax");
t.deepEqual(isObjLiteral(body_1.options.switches),true);
t.deepEqual(enumerableKeys(body_1.options.switches),2);//head and body
t.test("- default options", function(t) {
var body1 = {};
var options1 = {};
parseOptions.apply(body1, [options1]);
t.deepEqual(isObjLiteral(body_1.options.switchesOptions),true);
t.deepEqual(enumerableKeys(body_1.options.switchesOptions),0);
t.deepEqual(body1.options.elements, "a[href], form[action]");
t.deepEqual(body1.options.selectors.length, 2, "selectors length");
t.deepEqual(body1.options.selectors[0], "title");
t.deepEqual(body1.options.selectors[1], ".js-Pjax");
t.deepEqual(body_1.options.history,true);
t.deepEqual(isObjLiteral(body1.options.switches), true);
t.deepEqual(enumerableKeys(body1.options.switches), 2);// head and body
//TODO analytics is a little weird right now
t.deepEqual(typeof body_1.options.analytics,"function");
t.deepEqual(isObjLiteral(body1.options.switchesOptions), true);
t.deepEqual(enumerableKeys(body1.options.switchesOptions), 0);
t.deepEqual(body_1.options.scrollTo,0);
t.deepEqual(body_1.options.cacheBust,true);
t.deepEqual(body_1.options.debug,false);
t.deepEqual(body1.options.history, true);
// TODO analytics is a little weird right now
t.deepEqual(typeof body1.options.analytics, "function");
t.deepEqual(body1.options.scrollTo, 0);
t.deepEqual(body1.options.cacheBust, true);
t.deepEqual(body1.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 body_2 = {};
var options_2 = {analytics:"some string"};
parseOptions.apply(body_2,[options_2]);
// verify analytics always ends up as a function even when passed not a function
t.test("- analytics is a function", function(t) {
var body2 = {};
var options2 = {analytics: "some string"};
parseOptions.apply(body2, [options2]);
t.deepEqual(typeof body_2.options.analytics,"function");
t.deepEqual(typeof body2.options.analytics, "function");
t.end();
});
//verify that the value false for scrollTo is not squashed
t.test("- scrollTo remains false", function(t){
var body_3 = {};
var options_3 = {scrollTo:false};
parseOptions.apply(body_3,[options_3]);
// verify that the value false for scrollTo is not squashed
t.test("- scrollTo remains false", function(t) {
var body3 = {};
var options3 = {scrollTo: false};
parseOptions.apply(body3, [options3]);
t.deepEqual( body_3.options.scrollTo,false);
t.deepEqual(body3.options.scrollTo, false);
t.end();
});
t.end()
})
})

View File

@@ -6,9 +6,9 @@ var request = require("../../lib/request.js")
// just for the purposes of this test
// This polyfill is not complete; it won't show the updated location if a
// redirection occurred, but it's fine for our purposes.
if (!('responseURL' in XMLHttpRequest.prototype)) {
if (!("responseURL" in XMLHttpRequest.prototype)) {
var nativeOpen = XMLHttpRequest.prototype.open
XMLHttpRequest.prototype.open = function (method, url) {
XMLHttpRequest.prototype.open = function(method, url) {
this.responseURL = url
return nativeOpen.apply(this, arguments)
}

View File

@@ -8,7 +8,7 @@ tape("test switchesSelectors", function(t) {
// should really be passed in instead so I'll leave it here as a TODO:
var pjax = {
onSwitch: function() {
console.log('Switched')
console.log("Switched")
}
}
@@ -29,13 +29,13 @@ tape("test switchesSelectors", function(t) {
switchesSelectors.bind(pjax)(
{}, // switches
{}, // switchesOptions
['p'], //selectors,
["p"], // selectors,
tmpEl, // fromEl
document, // toEl,
{} // options
)
t.equals(container.innerHTML, '<p>New Text</p><span>No Change</span>', 'Elements correctly switched')
t.equals(container.innerHTML, "<p>New Text</p><span>No Change</span>", "Elements correctly switched")
t.end()
})