Skip to content

Commit 3a6c7fe

Browse files
fix tests
1 parent a4efcab commit 3a6c7fe

File tree

1 file changed

+27
-25
lines changed

1 file changed

+27
-25
lines changed

test/components.jl

+27-25
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ using JSON3
33

44
@testset "components creation" begin
55
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+
)
1111

1212
@test get_name(test_comp) == "html_div"
1313
@test get_type(test_comp) == "Div"
@@ -24,11 +24,11 @@ using JSON3
2424
@test_throws ErrorException test_comp.key
2525
@test_throws ErrorException test_comp.key = 20
2626
@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+
)
3232
json = JSON3.write(test_comp)
3333
res = JSON3.read(json)
3434
@test all(keys(res) .== [:type, :namespace, :props])
@@ -40,11 +40,11 @@ end
4040

4141
@testset "empty wilds" begin
4242
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+
)
4848

4949
@test get_name(test_comp) == "html_div"
5050
@test get_type(test_comp) == "Div"
@@ -55,17 +55,19 @@ end
5555
@test_throws ErrorException test_comp.var"data-id" = 20
5656
@test_throws ErrorException test_comp.aaaaa
5757
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
5961
@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+
])
6971
@test layout["target"].id == "target"
7072
@test layout["ups"] === nothing
7173
end

0 commit comments

Comments
 (0)