-
Notifications
You must be signed in to change notification settings - Fork 17
/
index.test.js
148 lines (141 loc) · 3.08 KB
/
index.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
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
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
import { h } from '.'
const hh = h('x', 'y', 'z')
const noop = x => x
const ListItem = data => ['li', data]
const Component = ({ title, story, related }) => [
'section',
[['h2', title], ['hr'], ['p', story], related.map(ListItem)],
]
const Main = [
'main',
[
'Hello',
['p', 0],
['h1', 'Hello World'],
['input', { type: 'range' }],
['ul', [1, 2, 3].map(ListItem)],
['button', { onclick: noop }, 'Log Event'],
false && ['span', 'Hidden'],
Component({
title: 'Some News',
story: 'lorem ipsum dolor sit amet',
related: [4, 5],
}),
],
]
const Button = ['button', { onclick: noop }, 'testing']
const Input = ['input', { type: 'range' }]
const Title = ['h1', 'testing']
const Zero = ['p', 0]
const Hr = ['hr']
export default {
Element: {
base: [
hh(Button),
{
x: 'button',
y: { onclick: noop },
z: ['testing'],
},
],
'no children': [
hh(Input),
{
x: 'input',
y: { type: 'range' },
z: [],
},
],
'no props': [
hh(Title),
{
x: 'h1',
y: {},
z: ['testing'],
},
],
'no props, no children': [
hh(Hr),
{
x: 'hr',
y: {},
z: [],
},
],
'children 0': [
hh(Zero),
{
x: 'p',
y: {},
z: ['0'],
},
],
'just string': [hh('Hello'), 'Hello'],
},
Nested: {
base: [
hh(['main', [Button]]),
{
x: 'main',
y: {},
z: [{ x: 'button', y: { onclick: noop }, z: ['testing'] }],
},
],
'base with string': [
hh(['main', [Button, 'Hello']]),
{
x: 'main',
y: {},
z: [{ x: 'button', y: { onclick: noop }, z: ['testing'] }, 'Hello'],
},
],
'no children': [
hh(['main', [Input]]),
{ x: 'main', y: {}, z: [{ x: 'input', y: { type: 'range' }, z: [] }] },
],
'no props': [
hh(['main', [Title]]),
{ x: 'main', y: {}, z: [{ x: 'h1', y: {}, z: ['testing'] }] },
],
'no props, no children': [
hh(['main', [Hr]]),
{ x: 'main', y: {}, z: [{ x: 'hr', y: {}, z: [] }] },
],
},
Component: {
base: [
hh(Main),
{
x: 'main',
y: {},
z: [
'Hello',
{ x: 'p', y: {}, z: ['0'] },
{ x: 'h1', y: {}, z: ['Hello World'] },
{ x: 'input', y: { type: 'range' }, z: [] },
{
x: 'ul',
y: {},
z: [
{ x: 'li', y: {}, z: ['1'] },
{ x: 'li', y: {}, z: ['2'] },
{ x: 'li', y: {}, z: ['3'] },
],
},
{ x: 'button', y: { onclick: noop }, z: ['Log Event'] },
{
x: 'section',
y: {},
z: [
{ x: 'h2', y: {}, z: ['Some News'] },
{ x: 'hr', y: {}, z: [] },
{ x: 'p', y: {}, z: ['lorem ipsum dolor sit amet'] },
{ x: 'li', y: {}, z: ['4'] },
{ x: 'li', y: {}, z: ['5'] },
],
},
],
},
],
},
}