-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathtest.js
More file actions
33 lines (27 loc) · 1.18 KB
/
Copy pathtest.js
File metadata and controls
33 lines (27 loc) · 1.18 KB
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
var virtual = require('./');
var test = require("prova");
var simple = '<div class="foo bar" style="color: red; background: yellow; background-image: url(http://f-oo.com/bar.jpg?qux=corge&span=eggs);" data-foo="bar" data-yo="hola" data-two-word="hello" for="woot">yo</div>';
test('creating virtual dom from HTML', function (t) {
t.plan(9);
virtual(simple, function (error, dom) {
if (error) t.error(error);
t.equal(dom.tagName.toLowerCase(), 'div');
t.equal(dom.children[0].text, 'yo');
t.equal(dom.properties.style.color, 'red');
t.equal(dom.properties.style.background, 'yellow');
t.equal(dom.properties.style['background-image'], 'url(http://f-oo.com/bar.jpg?qux=corge&span=eggs)');
t.equal(dom.properties.dataset.foo, 'bar');
t.equal(dom.properties.dataset.yo, 'hola');
t.equal(dom.properties.dataset.twoWord, 'hello');
t.equal(dom.properties.htmlFor, 'woot');
});
});
test('returns a virtual dom from HTML', function (t) {
t.plan(1);
var dom = virtual(simple);
t.equal(dom.tagName.toLowerCase(), 'div');
});
test('should throw if an error is found and no callback is provided', function (t) {
t.plan(1);
t.throws(virtual.bind(null, null));
});