Skip to content

Commit 04818ca

Browse files
committed
add process_callback_call test
with wrong current result, in the case where a callback has multiple outputs referencing the same component id
1 parent 49dd231 commit 04818ca

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

test/callbacks.jl

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,31 @@ end
120120
@test haskey(app.callbacks, Symbol("my-div.children"))
121121
@test app.callbacks[Symbol("my-div.children")].func("value", " value2") == "value value2"
122122

123+
end
124+
@testset "callback! multi output same component id" begin
125+
app = dash()
126+
app.layout = html_div() do
127+
dcc_input(id = "input-one",
128+
placeholder = "text or number?")
129+
dcc_input(id = "input-two",
130+
placeholder = "")
131+
end
132+
callback!(app, Output("input-two","placeholder"), Output("input-two","type"),
133+
Input("input-one","value")) do val1
134+
if val1 in ["text", "number"]
135+
return "$val1 ??", val1
136+
end
137+
return "invalid", nothing
138+
end
139+
@test length(app.callbacks) == 1
140+
@test haskey(app.callbacks, Symbol("..input-two.placeholder...input-two.type.."))
141+
@test app.callbacks[Symbol("..input-two.placeholder...input-two.type..")].func("text") == ("text ??", "text")
142+
@test Dash.process_callback_call(app,
143+
Symbol("..input-two.placeholder...input-two.type.."),
144+
[(id = "input-two", property = "placeholder"),
145+
(id = "input-two", property = "type")],
146+
[(value = "text",)], [])[:response] == Dict("input-two" => Dict(:type => "text"))
147+
123148
end
124149
@testset "callback! checks" begin
125150

0 commit comments

Comments
 (0)