-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
38 lines (33 loc) · 979 Bytes
/
test.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
require('jsdom-global')()
const assert = require('assert')
const $ = require('./')
const body = document.body
describe('Bianco query', function() {
before(function() {
const div = document.createElement('div')
div.innerHTML = `
<ul>
<li class='item'></li>
<li class='item'></li>
</ul>
`
body.appendChild(div)
})
it('It can query the DOM properly', function() {
const div = $('div')
assert.equal(typeof div, 'object')
assert.equal(div.length, 1)
assert.equal($('.item', div[0]).length, 2)
})
it('It can handle also DOM nodes', function() {
const els = $(document.querySelector('div')).concat($(document.querySelector('ul')))
assert.equal(typeof els, 'object')
assert.equal(els.length, 2)
})
it('No matched queries return empty arrays', function() {
const els = $('.foo')
assert.equal(Array.isArray(els), true)
assert.equal(typeof els, 'object')
assert.equal(els.length, 0)
})
})