forked from JuliaGizmos/Blink.jl
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added unit tests for src/content/api.jl
Includes a @test_throws which verifies the bug in JuliaGizmos#109. This passes before the fix: Test Summary: | Pass Total content! Tests | 7 7
- Loading branch information
Showing
2 changed files
with
37 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
using Blink | ||
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. | ||
@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) | ||
@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) | ||
@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" | ||
|
||
# Test `fade` parameter and scripts: | ||
fadeTestHtml = """<script>var testJS = "test";</script><div id="d">hi world</div>""" | ||
@testset "Fade True" begin | ||
# 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) | ||
@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) | ||
@test (@js w testJS) == "test" | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters