Add tests to ensure options are not accidentally modified
This commit is contained in:
@@ -76,3 +76,21 @@ tape("test attach form preventDefaulted events", function(t) {
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape("test options are not modified by attachForm", function(t) {
|
||||
var form = document.createElement("form")
|
||||
var options = {foo: "bar"}
|
||||
var loadUrl = () => {}
|
||||
|
||||
attachForm.call({options, loadUrl}, form)
|
||||
|
||||
var internalUri = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search
|
||||
form.action = internalUri
|
||||
form.method = "GET"
|
||||
trigger(form, "submit")
|
||||
|
||||
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();
|
||||
})
|
||||
|
||||
@@ -75,3 +75,21 @@ tape("test attach link preventDefaulted events", function(t) {
|
||||
|
||||
t.end()
|
||||
})
|
||||
|
||||
tape("test options are not modified by attachLink", function(t) {
|
||||
var a = document.createElement("a")
|
||||
var options = {foo: "bar"}
|
||||
var loadUrl = () => {};
|
||||
|
||||
attachLink.call({options, loadUrl}, a)
|
||||
|
||||
var internalUri = window.location.protocol + "//" + window.location.host + window.location.pathname + window.location.search
|
||||
a.href = internalUri
|
||||
|
||||
trigger(a, "click")
|
||||
|
||||
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();
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user