Skip to content

Commit d165554

Browse files
authored
test: Move to snapshot based tests (#84)
1 parent a335afd commit d165554

23 files changed

+1327
-47
lines changed

__snapshots__/src/index.test.js.md

Lines changed: 260 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,260 @@
1+
# Snapshot report for `src\index.test.js`
2+
3+
The actual snapshot is saved in `index.test.js.snap`.
4+
5+
Generated by [AVA](https://ava.li).
6+
7+
## renders default state
8+
9+
> Snapshot 1
10+
11+
<DropdownTreeSelect
12+
data={
13+
[
14+
{
15+
children: [
16+
{
17+
children: [
18+
{
19+
label: 'item1-1-1',
20+
value: 'value1-1-1',
21+
},
22+
{
23+
label: 'item1-1-2',
24+
value: 'value1-1-2',
25+
},
26+
],
27+
label: 'item1-1',
28+
value: 'value1-1',
29+
},
30+
{
31+
label: 'item1-2',
32+
value: 'value1-2',
33+
},
34+
],
35+
label: 'item1',
36+
value: 'value1',
37+
},
38+
{
39+
children: [
40+
{
41+
children: [
42+
{
43+
label: 'item2-1-1',
44+
value: 'value2-1-1',
45+
},
46+
{
47+
label: 'item2-1-2',
48+
value: 'value2-1-2',
49+
},
50+
{
51+
children: [
52+
{
53+
label: 'item2-1-3-1',
54+
value: 'value2-1-3-1',
55+
},
56+
],
57+
label: 'item2-1-3',
58+
value: 'value2-1-3',
59+
},
60+
],
61+
label: 'item2-1',
62+
value: 'value2-1',
63+
},
64+
{
65+
label: 'item2-2',
66+
value: 'value2-2',
67+
},
68+
],
69+
label: 'item2',
70+
value: 'value2',
71+
},
72+
]
73+
}
74+
>
75+
<div
76+
className="react-dropdown-tree-select"
77+
>
78+
<div
79+
className="dropdown"
80+
>
81+
<a
82+
className="dropdown-trigger arrow bottom"
83+
onClick={Function {}}
84+
>
85+
<Input
86+
inputRef={Function inputRef {}}
87+
onBlur={Function {}}
88+
onFocus={Function {}}
89+
onInputChange={Function {}}
90+
onTagRemove={Function {}}
91+
tags={[]}
92+
>
93+
<ul
94+
className="tag-list"
95+
>
96+
<li
97+
className="tag-item"
98+
>
99+
<input
100+
className="search"
101+
onBlur={Function {}}
102+
onChange={Function onInputChange {}}
103+
onFocus={Function {}}
104+
placeholder="Choose..."
105+
type="text"
106+
/>
107+
</li>
108+
</ul>
109+
</Input>
110+
</a>
111+
</div>
112+
</div>
113+
</DropdownTreeSelect>
114+
115+
## shows dropdown
116+
117+
> Snapshot 1
118+
119+
<div
120+
className="react-dropdown-tree-select"
121+
>
122+
<div
123+
className="dropdown"
124+
>
125+
<a
126+
className="dropdown-trigger arrow top"
127+
onClick={Function {}}
128+
>
129+
<Input
130+
inputRef={Function inputRef {}}
131+
onBlur={Function {}}
132+
onFocus={Function {}}
133+
onInputChange={Function {}}
134+
onTagRemove={Function {}}
135+
tags={[]}
136+
/>
137+
</a>
138+
<div
139+
className="dropdown-content"
140+
>
141+
<Tree
142+
data={
143+
Map {
144+
'0' => {
145+
_children: [
146+
'0-0',
147+
'0-1',
148+
],
149+
_depth: 0,
150+
_id: '0',
151+
children: undefined,
152+
label: 'item1',
153+
value: 'value1',
154+
},
155+
'0-0' => {
156+
_children: [
157+
'0-0-0',
158+
'0-0-1',
159+
],
160+
_depth: 1,
161+
_id: '0-0',
162+
_parent: '0',
163+
children: undefined,
164+
label: 'item1-1',
165+
value: 'value1-1',
166+
},
167+
'0-0-0' => {
168+
_depth: 2,
169+
_id: '0-0-0',
170+
_parent: '0-0',
171+
label: 'item1-1-1',
172+
value: 'value1-1-1',
173+
},
174+
'0-0-1' => {
175+
_depth: 2,
176+
_id: '0-0-1',
177+
_parent: '0-0',
178+
label: 'item1-1-2',
179+
value: 'value1-1-2',
180+
},
181+
'0-1' => {
182+
_depth: 1,
183+
_id: '0-1',
184+
_parent: '0',
185+
label: 'item1-2',
186+
value: 'value1-2',
187+
},
188+
'1' => {
189+
_children: [
190+
'1-0',
191+
'1-1',
192+
],
193+
_depth: 0,
194+
_id: '1',
195+
children: undefined,
196+
label: 'item2',
197+
value: 'value2',
198+
},
199+
'1-0' => {
200+
_children: [
201+
'1-0-0',
202+
'1-0-1',
203+
'1-0-2',
204+
],
205+
_depth: 1,
206+
_id: '1-0',
207+
_parent: '1',
208+
children: undefined,
209+
label: 'item2-1',
210+
value: 'value2-1',
211+
},
212+
'1-0-0' => {
213+
_depth: 2,
214+
_id: '1-0-0',
215+
_parent: '1-0',
216+
label: 'item2-1-1',
217+
value: 'value2-1-1',
218+
},
219+
'1-0-1' => {
220+
_depth: 2,
221+
_id: '1-0-1',
222+
_parent: '1-0',
223+
label: 'item2-1-2',
224+
value: 'value2-1-2',
225+
},
226+
'1-0-2' => {
227+
_children: [
228+
'1-0-2-0',
229+
],
230+
_depth: 2,
231+
_id: '1-0-2',
232+
_parent: '1-0',
233+
children: undefined,
234+
label: 'item2-1-3',
235+
value: 'value2-1-3',
236+
},
237+
'1-0-2-0' => {
238+
_depth: 3,
239+
_id: '1-0-2-0',
240+
_parent: '1-0-2',
241+
label: 'item2-1-3-1',
242+
value: 'value2-1-3-1',
243+
},
244+
'1-1' => {
245+
_depth: 1,
246+
_id: '1-1',
247+
_parent: '1',
248+
label: 'item2-2',
249+
value: 'value2-2',
250+
},
251+
}
252+
}
253+
onAction={Function {}}
254+
onCheckboxChange={Function {}}
255+
onNodeToggle={Function {}}
256+
searchModeOn={false}
257+
/>
258+
</div>
259+
</div>
260+
</div>

__snapshots__/src/index.test.js.snap

2.23 KB
Binary file not shown.
Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
# Snapshot report for `src\input\index.test.js`
2+
3+
The actual snapshot is saved in `index.test.js.snap`.
4+
5+
Generated by [AVA](https://ava.li).
6+
7+
## renders tags
8+
9+
> Snapshot 1
10+
11+
<ul
12+
className="tag-list"
13+
>
14+
<li
15+
className="tag-item"
16+
key="tag-item-i1"
17+
>
18+
<Tag
19+
id="i1"
20+
label="l1"
21+
/>
22+
</li>
23+
<li
24+
className="tag-item"
25+
key="tag-item-i2"
26+
>
27+
<Tag
28+
id="i2"
29+
label="l2"
30+
/>
31+
</li>
32+
<li
33+
className="tag-item"
34+
>
35+
<input
36+
className="search"
37+
onChange={Function onInputChange {}}
38+
placeholder="Choose..."
39+
type="text"
40+
/>
41+
</li>
42+
</ul
43+
44+
## renders input when no tags are passed
45+
46+
> Snapshot 1
47+
48+
<ul
49+
className="tag-list"
50+
>
51+
<li
52+
className="tag-item"
53+
>
54+
<input
55+
className="search"
56+
onChange={Function onInputChange {}}
57+
placeholder="Choose..."
58+
type="text"
59+
/>
60+
</li>
61+
</ul
62+
63+
## renders placeholder
64+
65+
> Snapshot 1
66+
67+
<ul
68+
className="tag-list"
69+
>
70+
<li
71+
className="tag-item"
72+
>
73+
<input
74+
className="search"
75+
onChange={Function onInputChange {}}
76+
placeholder="select something"
77+
type="text"
78+
/>
79+
</li>
80+
</ul
81+
82+
## should render data attributes
83+
84+
> Snapshot 1
85+
86+
<ul
87+
className="tag-list"
88+
>
89+
<li
90+
className="tag-item test"
91+
"data-first"="john"
92+
"data-last"="smith"
93+
key="tag-item-i1"
94+
>
95+
<Tag
96+
id="i1"
97+
label="l1"
98+
/>
99+
</li>
100+
<li
101+
className="tag-item"
102+
>
103+
<input
104+
className="search"
105+
onChange={Function onInputChange {}}
106+
placeholder="Choose..."
107+
type="text"
108+
/>
109+
</li>
110+
</ul>
864 Bytes
Binary file not shown.
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# Snapshot report for `src\tag\index.test.js`
2+
3+
The actual snapshot is saved in `index.test.js.snap`.
4+
5+
Generated by [AVA](https://ava.li).
6+
7+
## renders label when passed in
8+
9+
> Snapshot 1
10+
11+
<span
12+
className="tag"
13+
>
14+
hello
15+
<button
16+
className="tag-remove"
17+
onClick={Function onClick {}}
18+
type="button"
19+
>
20+
x
21+
</button>
22+
</span>
325 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)