loadUrl enhancements (#134)
`loadUrl` enhancements - Make `options` parameter optional - Allow partial overriding of instance options when calling `loadUrl` directly - Make `requestOptions` optional - Document `loadUrl` usage and provide examples
This commit was merged in pull request #134.
This commit is contained in:
@@ -1,17 +0,0 @@
|
||||
var tape = require("tape")
|
||||
|
||||
var clone = require("../../lib/clone")
|
||||
|
||||
tape("test clone method", function(t) {
|
||||
var obj = {one: 1, two: 2}
|
||||
var cloned = clone(obj)
|
||||
|
||||
t.notEqual(obj, cloned, "cloned object isn't the object")
|
||||
|
||||
t.same(obj, cloned, "cloned object have the same values than object")
|
||||
|
||||
cloned.tree = 3
|
||||
t.notSame(obj, cloned, "modified cloned object haven't the same values than object")
|
||||
|
||||
t.end()
|
||||
})
|
||||
@@ -1,10 +1,10 @@
|
||||
var tape = require("tape")
|
||||
|
||||
var parseOptions = require("../../../lib/proto/parse-options.js")
|
||||
var parseOptions = require("../../lib/parse-options.js")
|
||||
tape("test parse initalization options function", function(t) {
|
||||
t.test("- default options", function(t) {
|
||||
var pjax = {}
|
||||
parseOptions.call(pjax, {})
|
||||
pjax.options = parseOptions({})
|
||||
|
||||
t.equal(pjax.options.elements, "a[href], form[action]")
|
||||
t.equal(pjax.options.selectors.length, 2, "selectors length")
|
||||
@@ -30,7 +30,7 @@ tape("test parse initalization options function", function(t) {
|
||||
// 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"})
|
||||
pjax.options = parseOptions({analytics: "some string"})
|
||||
|
||||
t.deepEqual(typeof pjax.options.analytics, "function")
|
||||
t.end()
|
||||
@@ -39,7 +39,7 @@ tape("test parse initalization options function", function(t) {
|
||||
// verify that the value false for scrollTo is not squashed
|
||||
t.test("- scrollTo remains false", function(t) {
|
||||
var pjax = {}
|
||||
parseOptions.call(pjax, {scrollTo: false})
|
||||
pjax.options = parseOptions({scrollTo: false})
|
||||
|
||||
t.deepEqual(pjax.options.scrollTo, false)
|
||||
t.end()
|
||||
@@ -18,12 +18,7 @@ tape("test xhr request", function(t) {
|
||||
var url = "https://httpbin.org/get"
|
||||
|
||||
t.test("- request is made, gets a result, and is cache-busted", function(t) {
|
||||
var requestCacheBust = sendRequest.bind({
|
||||
options: {
|
||||
cacheBust: true
|
||||
}
|
||||
})
|
||||
var r = requestCacheBust(url, {}, function(result) {
|
||||
var r = sendRequest(url, {cacheBust: true}, function(result) {
|
||||
t.equal(r.responseURL.indexOf("?"), url.length, "XHR URL is cache-busted when configured to be")
|
||||
try {
|
||||
result = JSON.parse(result)
|
||||
@@ -36,12 +31,7 @@ tape("test xhr request", function(t) {
|
||||
})
|
||||
})
|
||||
t.test("- request is not cache-busted when configured not to be", function(t) {
|
||||
var requestNoCacheBust = sendRequest.bind({
|
||||
options: {
|
||||
cacheBust: false
|
||||
}
|
||||
})
|
||||
var r = requestNoCacheBust(url, {}, function() {
|
||||
var r = sendRequest(url, {}, function() {
|
||||
t.equal(r.responseURL, url, "XHR URL is left untouched")
|
||||
t.end()
|
||||
})
|
||||
|
||||
17
tests/lib/util/clone.js
Normal file
17
tests/lib/util/clone.js
Normal file
@@ -0,0 +1,17 @@
|
||||
var tape = require("tape")
|
||||
|
||||
var clone = require("../../../lib/util/clone")
|
||||
|
||||
tape("test clone method", function(t) {
|
||||
var obj = {one: 1, two: 2}
|
||||
var cloned = clone(obj)
|
||||
|
||||
t.notEqual(obj, cloned, "cloned object isn't the 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")
|
||||
|
||||
t.end()
|
||||
})
|
||||
16
tests/lib/util/extend.js
Normal file
16
tests/lib/util/extend.js
Normal file
@@ -0,0 +1,16 @@
|
||||
var tape = require("tape")
|
||||
|
||||
var extend = require("../../../lib/util/extend")
|
||||
|
||||
tape("test extend method", function(t) {
|
||||
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")
|
||||
|
||||
t.end()
|
||||
})
|
||||
Reference in New Issue
Block a user