Files
pjax/tests/lib/util/contains.js

26 lines
671 B
JavaScript
Raw Permalink Normal View History

2019-03-03 01:37:45 -05:00
var tape = require("tape");
2019-03-03 01:37:45 -05:00
var contains = require("../../../lib/util/contains.js");
tape("test contains function", function(t) {
2019-03-03 01:37:45 -05:00
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"
);
2019-03-03 01:37:45 -05:00
selectors = ["span"];
t.equal(
contains(tempDoc, selectors, el),
false,
"contains() returns false when the selectors do not contain the element"
);
2019-03-03 01:37:45 -05:00
t.end();
});