-
-
Notifications
You must be signed in to change notification settings - Fork 14
Expand file tree
/
Copy pathjsx.jsx
More file actions
119 lines (97 loc) · 2.24 KB
/
Copy pathjsx.jsx
File metadata and controls
119 lines (97 loc) · 2.24 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
import test from 'tape'
import {u} from 'unist-builder'
import {h} from '../index.js'
test('name', function (t) {
t.deepEqual(<a />, h('a'), 'should support a self-closing element')
t.deepEqual(<a>b</a>, h('a', 'b'), 'should support a value as a child')
var A = 'a'
t.deepEqual(<A />, h(A), 'should support an uppercase tag name')
t.deepEqual(
<a>{1 + 1}</a>,
h('a', '2'),
'should support expressions as children'
)
t.deepEqual(<></>, u('root', []), 'should support a fragment')
t.deepEqual(
<>a</>,
u('root', [u('text', 'a')]),
'should support a fragment with text'
)
t.deepEqual(
<>
<a />
</>,
u('root', [h('a')]),
'should support a fragment with an element'
)
t.deepEqual(
<>{-1}</>,
u('root', [u('text', '-1')]),
'should support a fragment with an expression'
)
var com = {acme: {a: 'A', b: 'B'}}
t.deepEqual(
<com.acme.a />,
h(com.acme.a),
'should support members as names (`a.b`)'
)
t.deepEqual(<a b />, h('a', {b: true}), 'should support a boolean attribute')
t.deepEqual(
<a b="" />,
h('a', {b: ''}),
'should support a double quoted attribute'
)
t.deepEqual(
<a b='"' />,
h('a', {b: '"'}),
'should support a single quoted attribute'
)
t.deepEqual(
<a b={1 + 1} />,
h('a', {b: 2}),
'should support expression value attributes'
)
var props = {a: 1, b: 2}
t.deepEqual(
<a {...props} />,
h('a', props),
'should support expression spread attributes'
)
t.deepEqual(
<a>
<b />c<d>e</d>
{1 + 1}
</a>,
h('a', [h('b'), 'c', h('d', 'e'), '2']),
'should support text, elements, and expressions in jsx'
)
t.deepEqual(
<a>
<>{1}</>
</a>,
h('a', '1'),
'should support a fragment in an element (#1)'
)
var dl = [
['Firefox', 'A red panda.'],
['Chrome', 'A chemical element.']
]
t.deepEqual(
<dl>
{dl.map(([title, definition]) => (
<>
<dt>{title}</dt>
<dd>{definition}</dd>
</>
))}
</dl>,
h('dl', [
h('dt', dl[0][0]),
h('dd', dl[0][1]),
h('dt', dl[1][0]),
h('dd', dl[1][1])
]),
'should support a fragment in an element (#2)'
)
t.end()
})