@@ -3,11 +3,11 @@ using JSON3
3
3
4
4
@testset " components creation" begin
5
5
test_comp = Component (" html_div" , " Div" , " dash_html_components" ,
6
- [:children , :id , :n_clicks ],
7
- [Symbol (" data-" ), Symbol (" aria-" )];
8
- id = 10 ,
9
- n_clicks = 1
10
- )
6
+ [:children , :id , :n_clicks ],
7
+ [Symbol (" data-" ), Symbol (" aria-" )];
8
+ id = 10 ,
9
+ n_clicks = 1
10
+ )
11
11
12
12
@test get_name (test_comp) == " html_div"
13
13
@test get_type (test_comp) == " Div"
@@ -24,11 +24,11 @@ using JSON3
24
24
@test_throws ErrorException test_comp. key
25
25
@test_throws ErrorException test_comp. key = 20
26
26
@test_throws ErrorException Component (" html_div" , " Div" , " dash_html_components" ,
27
- [:children , :id , :n_clicks ],
28
- [Symbol (" data-" ), Symbol (" aria-" )];
29
- id = 10 ,
30
- key = 1
31
- )
27
+ [:children , :id , :n_clicks ],
28
+ [Symbol (" data-" ), Symbol (" aria-" )];
29
+ id = 10 ,
30
+ key = 1
31
+ )
32
32
json = JSON3. write (test_comp)
33
33
res = JSON3. read (json)
34
34
@test all (keys (res) .== [:type , :namespace , :props ])
40
40
41
41
@testset " empty wilds" begin
42
42
test_comp = Component (" html_div" , " Div" , " dash_html_components" ,
43
- [:children , :id , :n_clicks ],
44
- Symbol[];
45
- id = 10 ,
46
- n_clicks = 1
47
- )
43
+ [:children , :id , :n_clicks ],
44
+ Symbol[];
45
+ id = 10 ,
46
+ n_clicks = 1
47
+ )
48
48
49
49
@test get_name (test_comp) == " html_div"
50
50
@test get_type (test_comp) == " Div"
55
55
@test_throws ErrorException test_comp. var"data-id" = 20
56
56
@test_throws ErrorException test_comp. aaaaa
57
57
end
58
-
58
+ function test_component (; kwargs... )
59
+ Component (" html_div" , " Div" , " dash_html_components" , [:dir , :n_clicks , :key , :loading_state , :contentEditable , :contextMenu , :n_clicks_timestamp , :draggable , :accessKey , :hidden , :style , :children , :id , :title , :role , :lang , :spellCheck , :tabIndex , :disable_n_clicks , :className ], Symbol[]; kwargs... )
60
+ end
59
61
@testset " Index by id" begin
60
- layout = html_div () do
61
- dcc_input (id = " my-id" , value = " initial value " , type = " text" ),
62
- html_div (id = " my-div" , children = [
63
- html_div (children = []),
64
- " string" ,
65
- html_div (id = " target" )
66
- ]),
67
- html_div (id = " my-div2" )
68
- end
62
+ layout = test_component (children = [
63
+ test_component (id= " my-id" , n_clicks = 0 , title = " text" ),
64
+ test_component (id= " my-div" , children= [
65
+ test_component (children= []),
66
+ " string" ,
67
+ test_component (id= " target" )
68
+ ]),
69
+ test_component (id= " my-div2" )
70
+ ])
69
71
@test layout[" target" ]. id == " target"
70
72
@test layout[" ups" ] === nothing
71
73
end
0 commit comments