2019-03-03 01:37:45 -05:00
|
|
|
var tape = require("tape");
|
2018-01-24 20:18:41 -05:00
|
|
|
|
2019-03-03 01:37:45 -05:00
|
|
|
var contains = require("../../../lib/util/contains.js");
|
2018-01-24 20:18:41 -05:00
|
|
|
|
|
|
|
|
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"
|
|
|
|
|
);
|
2018-01-24 20:18:41 -05:00
|
|
|
|
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"
|
|
|
|
|
);
|
2018-01-24 20:18:41 -05:00
|
|
|
|
2019-03-03 01:37:45 -05:00
|
|
|
t.end();
|
|
|
|
|
});
|