-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
38 lines (26 loc) · 949 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
var test = require('prova'),
listen = require('./');
test('allows an element to be appended', function(t){
t.plan(8);
document.body.innerHTML = '<div id="container"><h1>Roll over me</h1><button class="btn">Click Me</button><ul><li><a href="#" class="link">link</a></div>';
var container = document.getElementById('container');
function listener(){
t.ok(true);
}
var removeListeners = listen(container, {
//this one will get called every time because it selector is '*'
'click' : listener,
'click h1': listener,
'click .btn, .link': listener
});
t.ok(typeof removeListeners === 'function');
function sendClicks(){
container.click();
container.querySelector('h1').click();
container.querySelector('.btn').click();
container.querySelector('.link').click();
}
sendClicks();
removeListeners();
sendClicks();
});