-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.js
50 lines (45 loc) · 1.29 KB
/
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
39
40
41
42
43
44
45
46
47
48
49
50
import test from 'ava';
import { convertToHyperScript } from './muv';
import toHtml from 'snabbdom-to-html';
let emptyNode = {
sel: undefined,
data: {},
children: undefined,
text: undefined,
elm: undefined,
key: undefined
};
test('convertToHyperScript: text', t => {
t.is(convertToHyperScript('Hello'), 'Hello');
});
test('convertToHyperScript: sel', t => {
let hs = convertToHyperScript(['a']);
t.deepEqual(hs, { ...emptyNode, sel: 'a' });
t.is(toHtml(hs), '<a></a>');
});
test('convertToHyperScript: sel, data, text', t => {
let hs = convertToHyperScript(['a', { props: { href: 'http://todomvc.com' } }, 'TodoMVC']);
t.deepEqual(hs, {
...emptyNode,
sel: 'a',
data: { props: { href: 'http://todomvc.com' } },
children: [{ ...emptyNode, text: 'TodoMVC', data: undefined }]
});
t.is(toHtml(hs), '<a href="http://todomvc.com">TodoMVC</a>');
});
test('convertToHyperScript: sel, children', t => {
let hs = convertToHyperScript(['p', {}, ['div', {}, 42], 'Hello']);
t.deepEqual(hs, {
...emptyNode,
sel: 'p',
children: [
{
...emptyNode,
sel: 'div',
children: [{ ...emptyNode, text: 42, data: undefined }]
},
{ ...emptyNode, text: 'Hello', data: undefined }
]
});
t.is(toHtml(hs), '<p><div>42</div>Hello</p>');
});