mirror of
https://github.com/EnixCoda/Gitako.git
synced 2026-03-11 08:54:44 +00:00
git-subtree-dir: packages/pjax git-subtree-split: 8abb21e1e9d899217b03c489c9b2d9ecd92074b5
24 lines
819 B
JavaScript
24 lines
819 B
JavaScript
var tape = require("tape")
|
|
|
|
var forEachEls = require("../../lib/foreach-selectors.js")
|
|
|
|
var cb = function(el) {
|
|
el.className = "modified"
|
|
}
|
|
|
|
tape("test forEachSelector", function(t) {
|
|
forEachEls(["html", "body"], cb)
|
|
|
|
t.equal(document.documentElement.className, "modified", "callback has been executed on first selector")
|
|
t.equal(document.body.className, "modified", "callback has been executed on first selector")
|
|
|
|
document.documentElement.className = ""
|
|
document.body.className = ""
|
|
|
|
forEachEls(["html", "body"], cb, null, document.documentElement)
|
|
|
|
t.equal(document.documentElement.className, "", "callback has not been executed on first selector when context is used")
|
|
t.equal(document.body.className, "modified", "callback has been executed on first selector when context is used")
|
|
|
|
t.end()
|
|
})
|