Add tests to ensure options are not accidentally modified

This commit is contained in:
Tim Trinidad
2018-01-23 13:22:48 -05:00
parent 526a0883a2
commit f196604d73
3 changed files with 37 additions and 1 deletions

View File

@@ -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();
})

View File

@@ -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();
})