_ = require 'underscore'
DOMUtils = require '../src/dom-utils'
describe 'nodesWithContent', ->
tests = {
"": null
"
": null
"
": null
"""
""": ""
"""
Hello
""": "Hello"
"""
Hello
""": "Hello
"
"""
Hello
Foobar
""": "Foobar"
"""
Hello
""": "Hello"
"""
Hello
World
""": """World"""
"""
Hello
""": "Hello
"
"""
Hello
I'm hidden
""": "Hello
"
"""
Hello
I'm hidden
""": "Hello
"
}
it "tests nodesWithContent", ->
for input, output of tests
nodes = DOMUtils.nodesWithContent(input)
node = _.last(nodes) ? null
if node
tmp = document.createElement('div')
tmp.appendChild(node)
expect(tmp.innerHTML.trim()).toEqual output
else
expect(node).toEqual output