diff --git a/src/plotconfig.jl b/src/plotconfig.jl index addf46d35..579eeb9e2 100644 --- a/src/plotconfig.jl +++ b/src/plotconfig.jl @@ -59,6 +59,21 @@ end Takes a kwargs named tuple of Key => NamedTuple and merges the fields with the defaults """ function config_kwargs!(cfg::PlotConfig; kwargs...) + is_namedtuple = [isa(t,NamedTuple) for t in values(kwargs)] + @debug is_namedtuple + @assert(all(is_namedtuple), + """ Keyword-Argument specification (kwargs...) + + All your specified config-groups need to be `NamedTuples`, but: `$(keys(kwargs)[.!is_namedtuple])` was not. + Maybe you forgot the semicolon (;) in your specification? It should be: + + plot_example(...;layout = (;showColorbar=true)) + + and not: + + plot_example(...;layout = (showColorbar=true)) + + The former creates a NamedTuple as required, the later doesn't do something helpful in this case.""") list = fieldnames(PlotConfig)#[:layout,:visual,:mapping,:legend,:colorbar,:axis] keyList = collect(keys(kwargs)) :extra ∈ keyList ? @warn("Extra is deprecated in 0.4 and extra-keyword args have to be used directly as key-word arguments") : "" diff --git a/test/runtests.jl b/test/runtests.jl index ffeec4f7e..8227f4192 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -2,26 +2,30 @@ using UnfoldMakie include("setup.jl") #include("../src/UnfoldMakie.jl") -@testset "UnfoldMakie.jl" begin + +@testset "Test Config" begin + include("test_config.jl") +end +@testset "CircularEEGTopoPlot" begin include("test_plot_circulareegtopoplot.jl") end -@testset "UnfoldMakie.jl" begin +@testset "TopoSeries" begin include("test_toposeries.jl") end -@testset "UnfoldMakie.jl" begin +@testset "ERPImage" begin include("test_erpimage.jl") end -@testset "UnfoldMakie.jl" begin +@testset "TopoPlot" begin include("test_topoplot.jl") end -@testset "UnfoldMakie.jl" begin +@testset "Butterfly" begin include("test_butterfly.jl") end -@testset "UnfoldMakie.jl" begin +@testset "AllPlots" begin include("test_all.jl") end \ No newline at end of file diff --git a/test/test_config.jl b/test/test_config.jl new file mode 100644 index 000000000..aa5fad5b8 --- /dev/null +++ b/test/test_config.jl @@ -0,0 +1,9 @@ +@testset "config kwargs" begin + cfg = PlotConfig() + UnfoldMakie.config_kwargs!(cfg;visual=(;bla=:blub)) + @test cfg.visual.bla == :blub + + # now test that you cannot forget the ; - that is, cant forget to specify a NamedTuple + @test_throws AssertionError UnfoldMakie.config_kwargs!(cfg;visual=(bla=:blub)) + +end