Gitako/tests/lib/util/contains.js
EnixCoda 18ce99c8f6 Squashed 'packages/pjax/' content from commit 8abb21e
git-subtree-dir: packages/pjax
git-subtree-split: 8abb21e1e9d899217b03c489c9b2d9ecd92074b5
2018-06-05 23:48:45 +08:00

16 lines
624 B
JavaScript

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