From 8b39d73187425d779f9b79386ffe4cee8a0d5fc5 Mon Sep 17 00:00:00 2001 From: jwikmark <jacob@wikmark.se> Date: Fri, 9 Mar 2018 10:59:56 +0100 Subject: [PATCH] More tests --- src/gridmaker.jl | 2 +- test/runtests.jl | 66 ++++++++++++++++++++++++++++++++---------------- 2 files changed, 45 insertions(+), 23 deletions(-) diff --git a/src/gridmaker.jl b/src/gridmaker.jl index c382cc4..d9e87ba 100644 --- a/src/gridmaker.jl +++ b/src/gridmaker.jl @@ -14,7 +14,7 @@ Constructs a Node containing empty nodes in a row by column grid. A member can t """ -function make_grid(rows::Integer, columns::Integer, width = 800, height = 1000) +function make_grid(rows::Integer, columns::Integer, width = 500, height = 800) style_row = Dict(:height => "$(100/rows)%", :overflow => "auto") style_grid = Dict(:width => width, :height => height) Node(:div, style=style_grid, (Node(:div, style=style_row, make_row(columns)...) diff --git a/test/runtests.jl b/test/runtests.jl index 06baee1..69a63a1 100644 --- a/test/runtests.jl +++ b/test/runtests.jl @@ -3,14 +3,13 @@ using Observables using InteractNext using Base.Test -################################################## -a = Observables.Observable(5.0) -b = Observables.Observable(5.0) -f(x) = 2*x -g(x) = x/2 -link!(a,b, f, g) @testset "Tools" begin + a = Observables.Observable(5.0) + b = Observables.Observable(5.0) + f(x) = 2*x + g(x) = x/2 + link!(a,b, f, g) a[] = 3.0 @test b[] == 6.0 @@ -36,34 +35,57 @@ link!(a,b, f, g) @test d[] == 3.0 end -################################################## -grid = make_grid(3,5) + @testset "Gridmaker" begin + grid = make_grid(3,5) @test typeof(grid) <: WebIO.Node @test grid.children.length==3 @test grid.children[1].children.length==5 end -################################################## -gui = GUI() -wid1, graphic1 = @construct for dummy in 0:100 - Node(:div, dummy) -end +@testset "GUI" begin + gui = GUI() + wid1, graphic1 = @construct for dummy in 0:100 + Node(:div, dummy) + end -wid2, graphic2 = @construct for dummybox in checkbox(false) - Node(:div, dummybox) -end + wid2, graphic2 = @construct for dummybox in checkbox(false) + Node(:div, dummybox) + end -set!(gui, wid1) -set!(gui, graphic1) -add!(gui, wid2) -gui[:dummy] = 23 -@testset "GUI" begin + set!(gui, wid1) + set!(gui, graphic1) + add!(gui, wid2) + gui[:dummy] = 23 @test typeof(gui()) <: WebIO.Node @test obs(dummy)[] == 23 @test gui.widgets[:dummy] == dummy end -################################################## +@testset "SVG" begin + #Circle tests should suffice + circ = svg_circle(0,50,100) + @test typeof(circ) <: WebIO.Node + @test typeof(circ.instanceof) <: WebIO.DOM + @test circ.props[:attributes]["cx"] == "0" + @test circ.props[:attributes]["cy"] == "50" + @test circ.props[:style][:fill] == "rgb(0, 0, 0)" +end + + +@testset "Dependencies" begin + #testing vue + vuenode = Vue.vue(Node(:div)) + @test typeof(vuenode)<:WebIO.Scope + @test typeof(vuenode.dom)<:WebIO.Node + @test typeof(vuenode.id)==String + #testing interactnext + ui = @manipulate for dummy in 1:100 + WebIO.render(dummy) + end + @test typeof(ui) <: WebIO.Node{WebIO.DOM} + obs(dummy)[] = 80 + @test obs(dummy)[] == 80 +end -- GitLab