Skip to content

Commit

Permalink
Speed up test via synchronous content! calls
Browse files Browse the repository at this point in the history
Removed 5 `sleep(1)` statements, and reduced test time by 4.5 seconds:

```
$ time julia test/content/api.jl  # Before
julia test/content/api.jl  15.07s user 0.33s system 28% cpu 54.958 total
$ time julia test/content/api.jl  # After
julia test/content/api.jl  15.60s user 0.35s system 31% cpu 51.197 total
```
  • Loading branch information
NHDaly committed Aug 4, 2018
1 parent 944a41a commit 762d993
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions test/content/api.jl
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ using Base.Test

@testset "content! Tests" begin
w = Window(Blink.@d(:show => false)); sleep(5.0)
body!(w, ""); sleep(1.0) # body! is not synchronous.
body!(w, "", async=false);
@test (@js w document.querySelector("body").innerHTML) == ""

# Test reloading body and a selector element.
html = """<div id="a">hi world</div><div id="b">bye</div>"""
body!(w, html); sleep(1.0)
body!(w, html, async=false);
@test (@js w document.getElementById("a").innerHTML) == "hi world"
@test (@js w document.getElementById("b").innerHTML) == "bye"
content!(w, "div", "hello world"); sleep(1.0)
content!(w, "div", "hello world", async=false);
@test (@js w document.getElementById("a").innerHTML) == "hello world"
# TODO(nhdaly): Is this right? Should content!(w,"div",...) change _all_ divs?
@test (@js w document.getElementById("b").innerHTML) == "bye"
Expand All @@ -22,14 +22,14 @@ using Base.Test
# Must create a new window to ensure javascript is reset.
w = Window(Blink.@d(:show => false)); sleep(5.0)

body!(w, fadeTestHtml; fade=true); sleep(1.0)
body!(w, fadeTestHtml; fade=true, async=false);
@test (@js w testJS) == "test"
end
@testset "Fade False" begin
# Must create a new window to ensure javascript is reset.
w = Window(Blink.@d(:show => false)); sleep(5.0)

body!(w, fadeTestHtml; fade=false); sleep(1.0)
body!(w, fadeTestHtml; fade=false, async=false);
@test (@js w testJS) == "test"
end
end
Expand Down

0 comments on commit 762d993

Please sign in to comment.