@@ -3,12 +3,12 @@ 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
- )
11
-
6
+ [:children , :id , :n_clicks ],
7
+ [Symbol (" data-" ), Symbol (" aria-" )];
8
+ id = 10 ,
9
+ n_clicks = 1
10
+ )
11
+
12
12
@test get_name (test_comp) == " html_div"
13
13
@test get_type (test_comp) == " Div"
14
14
@test get_namespace (test_comp) == " dash_html_components"
@@ -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"
54
54
55
55
@test_throws ErrorException test_comp. var"data-id" = 20
56
56
@test_throws ErrorException test_comp. aaaaa
57
- end
57
+ end
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
61
+ @testset " Index by id" begin
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
+ ])
71
+ @test layout[" target" ]. id == " target"
72
+ @test layout[" ups" ] === nothing
73
+ end
0 commit comments