Prettier fixes

This commit is contained in:
Behind The Math
2019-03-03 01:37:45 -05:00
parent 3c1a4b2e18
commit c13149626b
32 changed files with 1318 additions and 903 deletions

View File

@@ -1,17 +1,21 @@
var tape = require("tape")
var tape = require("tape");
var clone = require("../../../lib/util/clone")
var clone = require("../../../lib/util/clone");
tape("test clone method", function(t) {
var obj = {one: 1, two: 2}
var cloned = clone(obj)
var obj = { one: 1, two: 2 };
var cloned = clone(obj);
t.notEqual(obj, cloned, "cloned object isn't the original object")
t.notEqual(obj, cloned, "cloned object isn't the original object");
t.same(obj, cloned, "cloned object has the same values as original object")
t.same(obj, cloned, "cloned object has the same values as original object");
cloned.three = 3
t.notSame(obj, cloned, "modified cloned object doesn't have the same values as original object")
cloned.three = 3;
t.notSame(
obj,
cloned,
"modified cloned object doesn't have the same values as original object"
);
t.end()
})
t.end();
});

View File

@@ -1,16 +1,25 @@
var tape = require("tape")
var tape = require("tape");
var contains = require("../../../lib/util/contains.js")
var contains = require("../../../lib/util/contains.js");
tape("test contains function", function(t) {
var tempDoc = document.implementation.createHTMLDocument()
tempDoc.body.innerHTML = "<div><p id='el' class='js-Pjax'></p></div><span></span>"
var selectors = ["div"]
var el = tempDoc.body.querySelector("#el")
t.equal(contains(tempDoc, selectors, el), true, "contains() returns true when a selector contains the element")
var tempDoc = document.implementation.createHTMLDocument();
tempDoc.body.innerHTML =
"<div><p id='el' class='js-Pjax'></p></div><span></span>";
var selectors = ["div"];
var el = tempDoc.body.querySelector("#el");
t.equal(
contains(tempDoc, selectors, el),
true,
"contains() returns true when a selector contains the element"
);
selectors = ["span"]
t.equal(contains(tempDoc, selectors, el), false, "contains() returns false when the selectors do not contain the element")
selectors = ["span"];
t.equal(
contains(tempDoc, selectors, el),
false,
"contains() returns false when the selectors do not contain the element"
);
t.end()
})
t.end();
});

View File

@@ -1,17 +1,25 @@
var tape = require("tape")
var tape = require("tape");
var extend = require("../../../lib/util/extend")
var extend = require("../../../lib/util/extend");
tape("test extend method", function(t) {
var obj = {one: 1, two: 2}
var obj = { one: 1, two: 2 };
var extended = extend({}, obj, {two: "two", three: 3})
t.notEqual(obj, extended, "extended object isn't the original object")
t.notSame(obj, extended, "extended object doesn't have the same values as original object")
t.notSame(obj.two, extended.two, "extended object value overwrites value from original object")
var extended = extend({}, obj, { two: "two", three: 3 });
t.notEqual(obj, extended, "extended object isn't the original object");
t.notSame(
obj,
extended,
"extended object doesn't have the same values as original object"
);
t.notSame(
obj.two,
extended.two,
"extended object value overwrites value from original object"
);
extended = extend(null)
t.equals(extended, null, "passing null returns null")
extended = extend(null);
t.equals(extended, null, "passing null returns null");
t.end()
})
t.end();
});

View File

@@ -1,9 +1,9 @@
var tape = require("tape")
var tape = require("tape");
var noop = require("../../../lib/util/noop")
var noop = require("../../../lib/util/noop");
tape("test noop function", function(t) {
t.equal(typeof noop, "function", "noop is a function")
t.equal(noop(), undefined, "noop() returns nothing")
t.end()
})
t.equal(typeof noop, "function", "noop is a function");
t.equal(noop(), undefined, "noop() returns nothing");
t.end();
});

View File

@@ -1,21 +1,33 @@
var tape = require("tape")
var tape = require("tape");
var updateQueryString = require("../../../lib/util/update-query-string")
var updateQueryString = require("../../../lib/util/update-query-string");
tape("test update query string method", function(t) {
var url = "http://example.com"
var updatedUrl = updateQueryString(url, "foo", "bar")
var url = "http://example.com";
var updatedUrl = updateQueryString(url, "foo", "bar");
t.notEqual(url, updatedUrl, "update query string modifies URL")
t.equal(updatedUrl, url + "?foo=bar", "update query string creates new query string when no query string params are set")
t.notEqual(url, updatedUrl, "update query string modifies URL");
t.equal(
updatedUrl,
url + "?foo=bar",
"update query string creates new query string when no query string params are set"
);
updatedUrl = updateQueryString(updatedUrl, "foo", "baz")
updatedUrl = updateQueryString(updatedUrl, "foo", "baz");
t.equal(updatedUrl, url + "?foo=baz", "update query string updates existing query string param")
t.equal(
updatedUrl,
url + "?foo=baz",
"update query string updates existing query string param"
);
updatedUrl = updateQueryString(updatedUrl, "bar", "")
updatedUrl = updateQueryString(updatedUrl, "bar", "");
t.equal(updatedUrl, url + "?foo=baz&bar=", "update query string appends to existing query string")
t.equal(
updatedUrl,
url + "?foo=baz&bar=",
"update query string appends to existing query string"
);
t.end()
})
t.end();
});